# 'seen' branch fails to build

2 messages from 2025-08-09 to 2025-08-10. Participants: Ramsay Jones, Junio C Hamano.
Thread: https://gitlist.dev/t/63936

## Ramsay Jones, 2025-08-09 13:34

Subject: 'seen' branch fails to build
Message-ID: <92c8c9eb-91de-48c6-88ac-7d5583cc766a@ramsayjones.plus.com>
URL: https://gitlist.dev/e/92c8c9eb-91de-48c6-88ac-7d5583cc766a%40ramsayjones.plus.com

```
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, 2025-08-10 00:16

Subject: Re: 'seen' branch fails to build
Message-ID: <xmqq5xew58vq.fsf@gitster.g>
URL: https://gitlist.dev/e/xmqq5xew58vq.fsf%40gitster.g
In-Reply-To: <92c8c9eb-91de-48c6-88ac-7d5583cc766a@ramsayjones.plus.com>

```
Ramsay Jones <ramsay@ramsayjones.plus.com> writes:

> 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;
 	}
 

```
