如何查看哪些提交实际上将被推送到远程存储库?
据我所知,每当我从远程存储库中提取master时,即使它们是空的,也可能会生成提交.
即使没有任何东西可以推动,这也会导致本地主人"前进".
现在,如果我尝试(来自主人):
git cherry origin master
Run Code Online (Sandbox Code Playgroud)
我知道将要推动什么,虽然这也显示了我已经推动的一些提交.有没有办法只显示要推送的新内容?
我正在研究一个有几个冲突的长度合并过程.
我可以做些什么来保存中间状态,以便定期保留备份以防万一?
我一直试图在Ubuntu上通过终端在VLC [2.2.1]中设置音量,但没有成功.
该参数--volume不再存在(Warning: option --volume no longer exists),我在帮助中找不到任何包含"volume"的内容.
文档(https://wiki.videolan.org/Documentation:Advanced_Use_of_VLC/)已过时,因为它仍然有--volume选项.
还有可能吗?
我有文件playground.go:
package main
import (
"fmt"
)
var GitCommit string
func main() {
fmt.Printf("Hello world, version: %s\n", GitCommit)
}
Run Code Online (Sandbox Code Playgroud)
为什么构建 ldflag 的行为-X取决于指定源文件名?:
# CASE 1
$ go build -ldflags "-X main.GitCommit=abc" && ./go_playground
Hello world, version:
$ go tool nm go_playground
52a900 D main.GitCommit
# CASE 2
$ go build -ldflags "-X main.GitCommit=abc" playground.go && ./playground
Hello world, version: abc
$ go tool nm playground
5242f0 D main.GitCommit
4c5678 R main.GitCommit.str
Run Code Online (Sandbox Code Playgroud)
编辑:当情况 1 从符号链接目录执行时,似乎会发生问题;当情况1从原始目录执行时,变量被传递。我不确定这是否是预期的,或者这是一个错误。
在Linux 文档项目中(我没有在Bash 手册中找到有关正则表达式元字符的详细信息),元字符^和$被定义为匹配行:
^: 匹配行首的空字符串 [...]
$: 匹配行尾的空字符串
但是,当我尝试时,这是不正确的:
$ string="a
> b
> c"
$ [[ $string =~ ^a ]] && echo BOS match
BOS match
$ [[ $string =~ ^b ]] && echo BOL match
# nothing
Run Code Online (Sandbox Code Playgroud)
手册真的错了,还是我遗漏了一些东西?
C 标准/编译器如何将负整数解释为单个文字,或解释为(一元)运算符和数字文字?
例如,被-16解释为 a-16或-(16)?
我正在\r\n使用 Perl v5.30 在 Linux上处理带有 Windows 行终止符 ( ) 的文本文件。
我不明白的是,为什么使用这些文本文件,捕获组与字符不匹配,而正则表达式匹配。
例子:
$ echo $'Line1\r\nLine2\n' | perl -ne 'print /(.*)/'
Line2
$ echo $'Line1\r\nLine2\n' | perl -ne '/(.*)/ && print "match\n"'
match
match
match
Run Code Online (Sandbox Code Playgroud)
第一行没有任何内容被捕获,但所有(三)行都匹配。
为什么会这样?
在《Rust for Rustaceans》一书中,作者写道:
\n\n\n但从广义上讲,您\xe2\x80\x99 将希望在库中使用静态调度,在二进制文件中使用动态调度。在图书馆中,您希望允许用户决定哪种调度最适合他们,因为您不知道他们的需求是什么。
\n
我猜想,在二进制情况下,他指的是:
\nfn flexible_dispatch_method(_: &dyn MyTrait) {}\n\n// static dispatch\n//\nlet obj = MyType {};\nflexible_dispatch_method(&obj);\n\n// dynamic dispatch\n//\nlet trait_obj: &dyn MyTrait = &MyType {};\nflexible_dispatch_method(trait_obj);\nRun Code Online (Sandbox Code Playgroud)\n鉴于上述情况,使用装箱对象而不是特征对象有什么优势?是不是因为需要使用生命周期:
\nfn return_new_trait_object<\'a>() -> &\'a dyn MyTrait {\n &MyType {}\n}\nRun Code Online (Sandbox Code Playgroud)\n或者还有别的什么?根据我的理解,在动态调度情况下,无论如何,对象需要在堆中分配,所以我认为与装箱对象没有太大区别。
\n我想模拟 Bash 函数的返回值,我想知道是否可以使用临时文件描述符来传递该值。
换句话说:
function myfunction {
# print `stdout_value` to stdout
# print `stderr_value` to stderr
# print `return_value` to FD3 (or other)
}
# the values printed to stderr/stdout should be printed, but only
# `return_value` should be assigned to `myvalue`
myvalue=$(myfunction <FDs manipulation>)
Run Code Online (Sandbox Code Playgroud) 为什么在下面的代码中,使用数组切片有效,但使用 a 的切片Vec无效?
use rand::{rngs::adapter::ReadRng, RngCore};
use std::io::Read;
struct MyRng {
rng: Box<dyn RngCore>,
}
pub fn main() {
// Version 1: error
//
let data = Vec::<u8>::new();
let data_slice = data.as_slice();
// Version 2: works
//
// let data_slice = &[0_u8][..];
// Version 3: error (!?!)
//
// let data = [0_u8];
// let data_slice = &data[..];
let read = Box::new(data_slice) as Box<dyn Read>;
let rng = Box::new(ReadRng::new(read));
// With this commented out, all versions work.
MyRng …Run Code Online (Sandbox Code Playgroud) 在 NASM 中,可以定义整数常量 ( equ),但是,对浮点值执行相同操作会导致错误:
section .data
c1 equ 3 ; ok
v2 dq 3.14 ; ok
c2 equ 3.14 ; not ok: `my.asm:7: error: expression syntax error`
Run Code Online (Sandbox Code Playgroud)
是否可以定义浮点常量?
我查过手册,但信息很少。
在 Perl (v5.30.0) 中,正则表达式被评估为捕获,当用作参数时print():
# Simplified example; the real case has more text, and the capture covers only part of it.
echo $'1\n2\n3' | perl -ne 'print /(.)/'
# 123
Run Code Online (Sandbox Code Playgroud)
这对于文本提取非常有用。我想利用算术运算的相同便利,但这并不能按预期工作:
# Attempt to compute a sum of the int value of the captures
#
echo $'1\n2\n3' | perl -ne '$tot += /(.)/; END { print $tot }'
# 3
# Attempt to print twice the int value of each capture
#
echo $'1\n2\n3' | perl -ne 'print(/(.)/ …Run Code Online (Sandbox Code Playgroud) 我正在尝试splash2x.raytrace在两种架构上编译一个程序(转换后的 PARSEC 基准套件包) - amd64 和 riscv64;但是,当我尝试在两者上本地编译它时,我得到了无法解释的不同行为。
具体来说,虽然在 amd64 上它编译,但在 riscv64 上它失败了很多multiple definition of....
该程序有大约十几个.c文件和一个标题,它们都包含在其中(“ rt.h”)。
样本变量是:
# File: rt.h
INT prims_in_leafs;
Run Code Online (Sandbox Code Playgroud)
导致错误:
/usr/bin/ld: cr.o:/home/riscv/parsec-benchmark/ext/splash2x/apps/raytrace/obj/riscv64-linux.gcc/rt.h:750: multiple definition of `prims_in_leafs'; bbox.o:/home/riscv/parsec-benchmark/ext/splash2x/apps/raytrace/obj/riscv64-linux.gcc/rt.h:750: first defined here
/usr/bin/ld: env.o:/home/riscv/parsec-benchmark/ext/splash2x/apps/raytrace/obj/riscv64-linux.gcc/rt.h:750: multiple definition of `prims_in_leafs'; bbox.o:/home/riscv/parsec-benchmark/ext/splash2x/apps/raytrace/obj/riscv64-linux.gcc/rt.h:750: first defined here
/usr/bin/ld: fbuf.o:/home/riscv/parsec-benchmark/ext/splash2x/apps/raytrace/obj/riscv64-linux.gcc/rt.h:750: multiple definition of `prims_in_leafs'; bbox.o:/home/riscv/parsec-benchmark/ext/splash2x/apps/raytrace/obj/riscv64-linux.gcc/rt.h:750: first defined here
/usr/bin/ld: geo.o:/home/riscv/parsec-benchmark/ext/splash2x/apps/raytrace/obj/riscv64-linux.gcc/rt.h:750: multiple definition of `prims_in_leafs'; bbox.o:/home/riscv/parsec-benchmark/ext/splash2x/apps/raytrace/obj/riscv64-linux.gcc/rt.h:750: first defined here
Run Code Online (Sandbox Code Playgroud)
用于编译的命令非常简单:
gcc -c -static-libgcc -pthread *.c
gcc *.o -pthread -o …Run Code Online (Sandbox Code Playgroud) bash ×2
c ×2
git ×2
perl ×2
regex ×2
rust ×2
assembly ×1
build ×1
command-line ×1
compilation ×1
constants ×1
gcc ×1
go ×1
internals ×1
ldflags ×1
lifetime ×1
line-endings ×1
linker ×1
literals ×1
merge ×1
nasm ×1
numeric ×1
parsing ×1
patch ×1
push ×1
riscv ×1
shell ×1
slice ×1
stdin ×1
stdout ×1
terminal ×1
traits ×1
vector ×1
vlc ×1
volume ×1
x86-64 ×1