Re: [PATCH v4 1/2] t6400: preserve git ls-files exit status code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Đoàn Trần Công Danh  <congdanhqx@xxxxxxxxx> writes:

>> Could be, except that I recall we saw extra noises like --out/--err
>> that weren't used and contaminating the current working directory,
>> which are gone from the latest iteration.
>
> Yes, in v{1,2}, there's the extra noises of --out and --err,
> but it's gone in v3.
>
> I guess you're thinking about the contamination of $PWD iff it's not
> a git worktree. That could be simplified by BUG-ging if $PWD is not
> a git worktree.

No.  I am not thinking about that.  I do not think it is a big loss
if the helper cannot be used in non-repository.

> Maybe, you're thinking about the extra noises to handle the failure run
> of command under check? That could be dropped, too.

No.  I am not thinking about that, either.

> Would you mind looking at v3 1/4 again to see what is your opinion
> there? I don't mind re-roll a same or simplified version of v3,
> with s/test_line_count_cmd/test_output_wc_l/ if you see fit.

Let's not go back that far.  This is taken from v4 (t/t6400) ...

	local ops val &&
	if test "$#" -le 2
	then
		BUG "Expect 2 or more arguments"
	fi &&
	ops="$1" &&
	val="$2" &&
	shift 2 &&
	mkdir -p .git/trash &&
	"$@" >.git/trash/output &&
	test_line_count "$ops" "$val" .git/trash/output

... except that it runs '"$@"' instead of 'git ls-files "$@"', so
that we could try running things other than ls-files, and that would
be mostly good enough.  We may want to be prepared for a caller who
wants to use the helper from within a subdirectory by not hardcoding
".git/trash", though.  Something along the lines of ...

	local ops val &&
+	local trashdir=$(git rev-parse --git-dir)/trash &&
	if test ...
	...
-	mkdir -p .git/trash &&
-	"$@" >".git/trash/output" &&
-	test_line_count "$ops" "$val" .git/trash/output
+	mkdir -p "$trashdir" &&
+	"$@" >"$trashdir/output" &&
+	test_line_count "$ops" "$val" "$trashdir/output"




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux