threads / discuss / 63936

'seen' branch fails to build

Subject: 'seen' branch fails to build

## tl;dr

2 messages between Aug 9, 2025 and Aug 10, 2025.

replies: 1people: 2as markdown or json

Ramsay Jones· Aug 9, 2025, 13:34 UTC · lore
Hi Junio,

You have probably already fixed this but, just in case you are unaware, the current 'seen' branch @9faf989da6 ("Merge branch 'gh/git-jump-pathname-with-sp' into seen", 2025-08-08) fails to build for me with DEVELOPER=1:

      CC builtin/diff.o
  builtin/diff.c: In function ‘cmd_diff’:
  builtin/diff.c:500:17: error: ignoring return value of ‘chdir’ declared with attribute ‘warn_unused_result’ [-Werror=unused-result]
    500 |                 chdir(prefix);
        |                 ^~~~~~~~~~~~~
  cc1: all warnings being treated as errors
  make: *** [Makefile:2818: builtin/diff.o] Error 1

See commit 456a265746 ("diff: --no-index should ignore the worktree", 2025-08-07) in the 'jc/diff-no-index-in-subdir' branch.

In order to get it to build, I just did:
  $ git diff
  diff --git a/builtin/diff.c b/builtin/diff.c
  index 3eb4cbb057..ff16d7be99 100644
  --- a/builtin/diff.c
  +++ b/builtin/diff.c
  @@ -497,7 +497,8 @@ int cmd_diff(int argc,
           * prefix.
           */
          if (no_index && prefix) {
  -               chdir(prefix);
  +               if (chdir(prefix) < 0)
  +                       die_errno(_("cannot chdir to %s"), prefix);
                  prefix = NULL;
          }
   
  $ 
[I don't know if that is the best solution; it was just the quickest! :) ]

ATB, Ramsay Jones

 
Junio C Hamano· Aug 10, 2025, 00:16 UTC · re: Ramsay Jones · lore

Re: 'seen' branch fails to build

Ramsay Jones <ramsay@ramsayjones.plus.com> writes:
Show 5 quoted lines
> See commit 456a265746 ("diff: --no-index should ignore the worktree",
> 2025-08-07) in the 'jc/diff-no-index-in-subdir' branch.
>
> In order to get it to build, I just did:
> ...

Thanks for noticing and reporting. I'd save the translators by reusing the message used already elsewhere.

 builtin/diff.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git c/builtin/diff.c w/builtin/diff.c
index 3eb4cbb057..0b23c41456 100644
--- c/builtin/diff.c
+++ w/builtin/diff.c
@@ -497,7 +497,8 @@ int cmd_diff(int argc,
 	 * prefix.
 	 */
 	if (no_index && prefix) {
-		chdir(prefix);
+		if (chdir(prefix))
+			die(_("cannot come back to cwd"));
 		prefix = NULL;
 	}
 

← back to recent threads