@matheusbsbs / matheus-bagliano / commits / 50fd9bd843
Fork 0

diff options: Introduce --ignore-submodules

The new option --ignore-submodules can now be used to ignore changes in submodules. Why? Sometimes it is not interesting when a submodule changed. For example, when reordering some commits in the superproject, a dirty submodule is usually totally uninteresting. So we will use this option in git-rebase to test for a dirty working tree. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johannes Schindelin committed May 14, 2008 at 18:03 UTC 50fd9bd8430a957ea6c6674ce6112f375985abbc
3 files changed +13
Documentation/diff-options.txt
+3
@@ -228,6 +228,9 @@ endif::git-format-patch[]
228 --no-ext-diff::
229 Disallow external diff drivers.
230
231 +--ignore-submodules::
232 + Ignore changes to submodules in the diff generation.
233 +
234 --src-prefix=<prefix>::
235 Show the given source prefix instead of "a/".
236
diff.c
+9
@@ -2496,6 +2496,8 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
2496 DIFF_OPT_SET(options, ALLOW_EXTERNAL);
2497 else if (!strcmp(arg, "--no-ext-diff"))
2498 DIFF_OPT_CLR(options, ALLOW_EXTERNAL);
2499 + else if (!strcmp(arg, "--ignore-submodules"))
2500 + DIFF_OPT_SET(options, IGNORE_SUBMODULES);
2501
2502 /* misc options */
2503 else if (!strcmp(arg, "-z"))
@@ -3355,6 +3357,9 @@ void diff_addremove(struct diff_options *options,
3357 char concatpath[PATH_MAX];
3358 struct diff_filespec *one, *two;
3359
3360 + if (DIFF_OPT_TST(options, IGNORE_SUBMODULES) && S_ISGITLINK(mode))
3361 + return;
3362 +
3363 /* This may look odd, but it is a preparation for
3364 * feeding "there are unchanged files which should
3365 * not produce diffs, but when you are doing copy
@@ -3399,6 +3404,10 @@ void diff_change(struct diff_options *options,
3404 char concatpath[PATH_MAX];
3405 struct diff_filespec *one, *two;
3406
3407 + if (DIFF_OPT_TST(options, IGNORE_SUBMODULES) && S_ISGITLINK(old_mode)
3408 + && S_ISGITLINK(new_mode))
3409 + return;
3410 +
3411 if (DIFF_OPT_TST(options, REVERSE_DIFF)) {
3412 unsigned tmp;
3413 const unsigned char *tmp_c;
diff.h
+1
@@ -63,6 +63,7 @@ typedef void (*diff_format_fn_t)(struct diff_queue_struct *q,
63 #define DIFF_OPT_REVERSE_DIFF (1 << 15)
64 #define DIFF_OPT_CHECK_FAILED (1 << 16)
65 #define DIFF_OPT_RELATIVE_NAME (1 << 17)
66 +#define DIFF_OPT_IGNORE_SUBMODULES (1 << 18)
67 #define DIFF_OPT_TST(opts, flag) ((opts)->flags & DIFF_OPT_##flag)
68 #define DIFF_OPT_SET(opts, flag) ((opts)->flags |= DIFF_OPT_##flag)
69 #define DIFF_OPT_CLR(opts, flag) ((opts)->flags &= ~DIFF_OPT_##flag)