[PATCH] Allow git-diff exit with codes similar to diff(1)

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

 



This introduces a new command-line option: --exit-code. The diff
programs will return 1 for differences, return 0 for equality, and
something else for errors.

Signed-off-by: Alex Riesen <raa.lkml@xxxxxxxxx>
---

Updated patch:
- implemented exit_with_status+has_changes
- fixed test WRT intermediate failures

On 3/14/07, Junio C Hamano <junkio@xxxxxxx> wrote:
"Alex Riesen" <raa.lkml@xxxxxxxxx> writes:

>>         echo ... &&
>>         git add . &&
>>         {
>>                 git diff-index ...; test $? != 0
>>         }
>
> Confused. What's wrong with test_expect_failure which
> does not need any of the both ugly constructions?
> Hmm... Do you mean: "we expect successful
> operation with exit code 1"?

No.  Think what happens if you broke "git add".


Right. Figured that out myself while changing the test.
Removed all test_expect_failure anyway: not that I
actually expect a failure, just exit code. Made the test
stricter, too: it must be either 0 or 1. Anything else
considered test failure.

Documentation/diff-options.txt |    5 +++
builtin-diff-files.c           |    4 ++-
builtin-diff-index.c           |    4 ++-
builtin-diff-tree.c            |    5 ++-
builtin-diff.c                 |   19 ++++++----
diff-lib.c                     |    5 ++-
diff.c                         |    6 +++
diff.h                         |    5 ++-
t/t4017-diff-retval.sh         |   79 ++++++++++++++++++++++++++++++++++++++++
9 files changed, 118 insertions(+), 14 deletions(-)
create mode 100755 t/t4017-diff-retval.sh

Attachment: 0001-Allow-git-diff-exit-with-codes-similar-to-diff-1.patch
Description: application/xxxxx


[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]