"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Mark Jamsek <mark@jamsek.com>
Subject:
Re: make worktree diffs record xbit of new files
To:
Game of Trees <gameoftrees@openbsd.org>
Date:
Thu, 22 Sep 2022 17:40:56 +1000

Download raw body.

Thread
On 22-09-21 10:22PM, Mark Jamsek wrote:
> Related to the recent work: when running `got diff` in a worktree with
> a file that has the x-bit and has been added with `got add`, we don't
> presently record this mode like we do with `got diff obj1 obj2` or
> `got diff -c obj`.
> 
> The below change makes `got diff` in a worktree record this information
> like other diff modes.

Actually, there's more to consider; in the latest got tree, if you run:

  $ got log -p -l1

and check the diff header for regress/cmdline/diff.sh, it doesn't record
the file mode:

----8<------
blob - 43f41172dfa14e7ca103f635f10f4b25a6f11cf8
blob + 3dd406d46df77adc838bdfc9be2f93687dcf69d8
--- regress/cmdline/diff.sh
+++ regress/cmdline/diff.sh
@@ -1327,6 +1327,48 @@ EOF
------>8----

Git, however, does:

----8<------
diff --git a/regress/cmdline/diff.sh b/regress/cmdline/diff.sh
index 43f41172..3dd406d4 100755
--- a/regress/cmdline/diff.sh
+++ b/regress/cmdline/diff.sh
@@ -1327,6 +1327,48 @@ EOF
------>8----

Git also shows the file mode for managed files in worktree diffs too.
Currently, before the proposed diff ITT, got does not.

What do we actually want to do here? It seems at present we only record
the file mode for newly added files with all `got diff` formats _except_
for worktree diffs. I think we should be consistent and show the same
info in all `got diff` modes.  Otherwise, the proposed diff should be
modified to only show the file mode in worktree diffs for new
files--like we already do for our other diffs.

I think at least one of the above is needed, however, because at
present, a worktree diff of a new added file with +x doesn't contain
that information. So `got patch` will fail to set the x-bit.

In sum:

  - `got diff obj obj` and `got diff -c obj [-c obj]` show the file mode
    for _new_ +x files; however, this is not shown for changed files
  - `got diff` in a work tree does not show this information for neither
    new nor changed files
  - all versions of `git diff` show the file mode for both new and
    changed files

-- 
Mark Jamsek <fnc.bsdbox.org>
GPG: F2FF 13DE 6A06 C471 CA80  E6E2 2930 DC66 86EE CF68