diff.h: extend "flags" field to 64 bits because we're out of bits
A message that is not in the archive (sent off-list or not yet received): 1440205700-19749-1-git-send-email-pclouds
PATCH 7/8 diff.h: extend "flags" field to 64 bits because we're out of bits
I renamed both "flags" and "touched_flags" fields while making this patch to make sure I was aware of how these flags were manipulated (besides DIFF_OPT* macros). So hopefully I didn't miss anything.
---
Resend to the right recipients. I screwed send-email up..
builtin/commit.c | 2 +- diff-lib.c | 4 ++-- diff.c | 2 +- diff.h | 8 +++++--- 4 files changed, 9 insertions(+), 7 deletions(-)
builtin/commit.c +1 -1
@@ -895,7 +895,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,* submodules which were manually staged, which would * be really confusing. */ -int diff_flags =DIFF_OPT_OVERRIDE_SUBMODULE_CONFIG ; +diff_flags_t diff_flags =DIFF_OPT_OVERRIDE_SUBMODULE_CONFIG ;if (ignore_submodule_arg && !strcmp (ignore_submodule_arg,"all" )) diff_flags |=DIFF_OPT_IGNORE_SUBMODULES ;
diff-lib.c +2 -2
@@ -71,7 +71,7 @@ static int match_stat_with_submodule(struct diff_options *diffopt, {int changed =ce_match_stat (ce, st, ce_option);if (S_ISGITLINK (ce->ce_mode)) { -unsigned orig_flags = diffopt->flags; +diff_flags_t orig_flags = diffopt->flags;if (!DIFF_OPT_TST (diffopt,OVERRIDE_SUBMODULE_CONFIG ))set_diffopt_flags_from_submodule_config (diffopt, ce->name);if (DIFF_OPT_TST (diffopt,IGNORE_SUBMODULES ))
@@ -516,7 +516,7 @@ int do_diff_cache(const unsigned char *tree_sha1, struct diff_options *opt)return 0 ; } -int index_differs_from (const char *def,int diff_flags) +int index_differs_from (const char *def,diff_flags_t diff_flags) {struct rev_info rev;struct setup_revision_opt opt;
diff.c +1 -1
@@ -4912,7 +4912,7 @@ int diff_can_quit_early(struct diff_options *opt)static int is_submodule_ignored (const char *path,struct diff_options *options) {int ignored =0 ; -unsigned orig_flags = options->flags; +diff_flags_t orig_flags = options->flags;if (!DIFF_OPT_TST (options,OVERRIDE_SUBMODULE_CONFIG ))set_diffopt_flags_from_submodule_config (options, path);if (DIFF_OPT_TST (options,IGNORE_SUBMODULES ))
diff.h +5 -3
@@ -110,13 +110,15 @@ enum diff_words_type {DIFF_WORDS_COLOR }; +typedef uint64_t diff_flags_t ; +struct diff_options {const char *orderfile;const char *pickaxe;const char *single_follow;const char *a_prefix, *b_prefix; -unsigned flags; -unsigned touched_flags; +diff_flags_t flags; +diff_flags_t touched_flags;/* diff-filter bits */ unsigned int filter;
@@ -347,7 +349,7 @@ extern int diff_result_code(struct diff_options *, int);extern void diff_no_index (struct rev_info *,int ,const char **,const char *); -extern int index_differs_from (const char *def,int diff_flags); +extern int index_differs_from (const char *def,diff_flags_t diff_flags); extern size_t fill_textconv(struct userdiff_driver *driver, struct diff_filespec *df,
Signature · 1 line
2.3.0.rc1.137.g477eb31
PATCH 8/8 Resurrect "diff-lib.c: adjust position of i-t-a entries in diff"
In reply to a message not in the archiveThe original commit d95d728aba06a34394d15466045cbdabdada58a2 was reverted in commit 78cc1a540ba127b13f2f3fd531777b57f3a9cd46 because we were (and still are) not ready for a new world order. A lot more investigation must be done to see what is impacted. See the 78cc1a5 for details.
This patch takes a smaller and safer step. The new behavior is controlled by SHIFT_INTENT_TO_ADD flag. We can gradually move more diff users to the new behavior after we are sure it's safe to do so. This flag is exposed to outside as "--shift-ita".
"git status" sets this flag unconditionally to display i-t-a entries correctly. See d95d728 for details about "git status" and i-t-a entries.
--- Documentation/diff-options.txt | 6 ++++++ diff-lib.c | 14 ++++++++++++++ diff.c | 2 ++ diff.h | 1 + t/t2203-add-intent.sh | 20 ++++++++++++++++++-- wt-status.c | 2 ++ 6 files changed, 43 insertions(+), 2 deletions(-)
Documentation/diff-options.txt +6 -0
@@ -556,5 +556,11 @@ endif::git-format-patch[] --no-prefix:: Do not show any source or destination prefix. +--shift-ita:: + By default entries added by "git add -N" appear as an existing + empty file in "git diff" and a new file in "git diff --cached". + This option makes the entry appear as a new file in "git diff" + and non-existent in "git diff --cached". + For more detailed explanation on these common options, see also linkgit:gitdiffcore[7].
diff-lib.c +14 -0
@@ -212,6 +212,12 @@ int run_diff_files(struct rev_info *revs, unsigned int option) ce->sha1, !is_null_sha1 (ce->sha1), ce->name, 0);continue ; + }else if (DIFF_OPT_TST (&revs->diffopt,SHIFT_INTENT_TO_ADD ) && +ce_intent_to_add (ce)) { +diff_addremove (&revs->diffopt,'+' , ce->ce_mode, +EMPTY_BLOB_SHA1_BIN ,0 , + ce->name,0 ); +continue ; } changed = match_stat_with_submodule(&revs->diffopt, ce, &st,
@@ -376,6 +382,14 @@ static void do_oneway_diff(struct unpack_trees_options *o,struct rev_info *revs = o->unpack_data;int match_missing, cached; +/* i-t-a entries do not actually exist in the index */ +if (DIFF_OPT_TST (&revs->diffopt,SHIFT_INTENT_TO_ADD ) && + idx &&ce_intent_to_add (idx)) { + idx =NULL ; +if (!tree) +return ;/* nothing to diff.. */ + } +/* if the entry is not checked out, don't examine work tree */ cached = o->index_only || (idx && ((idx->ce_flags &CE_VALID ) ||ce_skip_worktree (idx)));
diff.c +2 -0
@@ -3890,6 +3890,8 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)return parse_submodule_opt (options, arg); else if (skip_prefix(arg, "--ws-error-highlight=", &arg))return parse_ws_error_highlight (options, arg); + else if (!strcmp(arg, "--shift-ita")) +DIFF_OPT_SET (options,SHIFT_INTENT_TO_ADD );/* misc options */ else if (!strcmp(arg, "-z"))
diff.h +1 -0
@@ -92,6 +92,7 @@ typedef struct strbuf *(*diff_prefix_fn_t)(struct diff_options *opt, void *data)#define DIFF_OPT_FUNCCONTEXT (1 << 29)#define DIFF_OPT_PICKAXE_IGNORE_CASE (1 << 30)#define DIFF_OPT_DEFAULT_FOLLOW_RENAMES (1 << 31) +#define DIFF_OPT_SHIFT_INTENT_TO_ADD (1ULL << 32)#define DIFF_OPT_TST (opts, flag) ((opts)->flags & DIFF_OPT_##flag)#define DIFF_OPT_TOUCHED (opts, flag) ((opts)->touched_flags & DIFF_OPT_##flag)
t/t2203-add-intent.sh +18 -2
@@ -5,10 +5,24 @@ test_description='Intent to add' . ./test-lib.sh test_expect_success 'intent to add' ' + test_commit 1 && + git rm 1.t && + echo hello >1.t && echo hello >file && echo hello >elif && git add -N file && - git add elif + git add elif && + git add -N 1.t +' + +test_expect_success 'git status' ' + git status --porcelain | grep -v actual >actual && + cat >expect <<-\EOF && + DA 1.t + A elif + A file + EOF + test_cmp expect actual ' test_expect_success 'check result of "add -N"' '
@@ -43,7 +57,9 @@ test_expect_success 'i-t-a entry is simply ignored' ' git add -N nitfol && git commit -m second && test $(git ls-tree HEAD -- nitfol | wc -l) = 0 && - test $(git diff --name-only HEAD -- nitfol | wc -l) = 1 + test $(git diff --name-only HEAD -- nitfol | wc -l) = 1 && + test $(git diff --name-only --shift-ita HEAD -- nitfol | wc -l) = 0 && + test $(git diff --name-only --shift-ita -- nitfol | wc -l) = 1 ' test_expect_success 'can commit with an unrelated i-t-a entry in index' '
wt-status.c +2 -0
@@ -497,6 +497,7 @@ static void wt_status_collect_changes_worktree(struct wt_status *s)setup_revisions (0 ,NULL , &rev,NULL ); rev.diffopt.output_format |=DIFF_FORMAT_CALLBACK ;DIFF_OPT_SET (&rev.diffopt,DIRTY_SUBMODULES ); +DIFF_OPT_SET (&rev.diffopt,SHIFT_INTENT_TO_ADD );if (!s->show_untracked_files)DIFF_OPT_SET (&rev.diffopt,IGNORE_UNTRACKED_IN_SUBMODULES );if (s->ignore_submodule_arg) {
@@ -520,6 +521,7 @@ static void wt_status_collect_changes_index(struct wt_status *s)setup_revisions (0 ,NULL , &rev, &opt);DIFF_OPT_SET (&rev.diffopt,OVERRIDE_SUBMODULE_CONFIG ); +DIFF_OPT_SET (&rev.diffopt,SHIFT_INTENT_TO_ADD );if (s->ignore_submodule_arg) {handle_ignore_submodules_arg (&rev.diffopt, s->ignore_submodule_arg); }else {
Signature · 1 line
2.3.0.rc1.137.g477eb31