Convert some match_pathspec_depth() to ce_path_match()

This helps reduce the number of match_pathspec_depth() call sites and
show how match_pathspec_depth() is used.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Convert some match_pathspec_depth() to dir_path_match()

This helps reduce the number of match_pathspec_depth() call sites and
show how m_p_d() is used. And it usage is:

 - match against an index entry (ce_path_match or match_pathspec_depth
   in ls-files)

 - match against a dir_entry from read_directory (dir_path_match and
   match_pathspec_depth in clean.c, which will be converted later)

 - resolve-undo (rerere.c and ls-files.c)

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Rename match_pathspec_depth() to match_pathspec()

A long time ago, for some reason I was not happy with
match_pathspec(). I created a better version, match_pathspec_depth()
that was suppose to replace match_pathspec()
eventually. match_pathspec() has finally been gone since 6 months
ago. Use the shorter name for match_pathspec_depth().

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
dir.c: prepare match_pathspec_item for taking more flags

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
match_pathspec: match pathspec "foo/" against directory "foo"

Currently we do support matching pathspec "foo/" against directory
"foo". That is because match_pathspec() has no way to tell "foo" is a
directory and matching "foo/" against _file_ "foo" is wrong.

The callers can now tell match_pathspec if "foo" is a directory, we
could make an exception for this case. Code is not executed though
because no callers pass the flag yet.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Pass directory indicator to match_pathspec_item()

This patch activates the DO_MATCH_DIRECTORY code in m_p_i(), which
makes "git diff HEAD submodule/" and "git diff HEAD submodule" produce
the same output. Previously only the version without trailing slash
returns the difference (if any).

That's the effect of new ce_path_match(). dir_path_match() is not
executed by the new tests. And it should not introduce regressions.

Previously if path "dir/" is passed in with pathspec "dir/", they
obviously match. With new dir_path_match(), the path becomes
_directory_ "dir" vs pathspec "dir/", which is not executed by the old
code path in m_p_i(). The new code path is executed and produces the
same result.

The other case is pathspec "dir" and path "dir/" is now turned to
"dir" (with DO_MATCH_DIRECTORY). Still the same result before or after
the patch.

So why change? Because of the next patch about clean.c.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
clean: replace match_pathspec() with dir_path_match()

This instance was left out when many match_pathspec() call sites that
take input from dir_entry were converted to dir_path_match() because
it passed a path with the trailing slash stripped out to match_pathspec()
while the others did not. Stripping for all call sites back then would
be a regression because match_pathspec() did not know how to match
pathspec foo/ against _directory_ foo (the stripped version of path
"foo/").

match_pathspec() knows how to do it now. And dir_path_match() strips
the trailing slash also. Use the new function, because the stripping
code is removed in the next patch.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
clean: use cache_name_is_other()

cmd_clean() has the exact same code of index_name_is_other(). Reduce
code duplication.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Merge branch 'bk/refresh-missing-ok-in-merge-recursive' into jch

* bk/refresh-missing-ok-in-merge-recursive:
  merge-recursive.c: Tolerate missing files while refreshing index
  read-cache.c: Extend make_cache_entry refresh flag with options
  read-cache.c: Refactor --ignore-missing implementation
  t3030-merge-recursive: Test known breakage with empty work tree
Merge branch 'nd/diff-quiet-stat-dirty' into jch

* nd/diff-quiet-stat-dirty:
  diff: turn off skip_stat_unmatch on "diff --cached"
  diff: do not quit early on stat-dirty files
  Move diffcore_skip_stat_unmatch core logic out for reuse later
Merge branch 'jk/branch-at-publish-rebased' into jch

Give an easier access to the tracking branches from "other" side in
a triangular workflow by introducing B@{publish} that works in a
similar way to how B@{upstream} does.

Will hold.

* jk/branch-at-publish-rebased:
  t1507 (rev-parse-upstream): fix typo in test title
  implement @{publish} shorthand
  branch_get: provide per-branch pushremote pointers
  branch_get: return early on error
  sha1_name: refactor upstream_mark
Merge branch 'rb/merge-prepare-commit-msg-hook' into jch

Expose more merge states (e.g. $GIT_DIR/MERGE_MODE) to hooks that
run during "git merge".  The log message stresses too much on one
hook, prepare-commit-msg, but it would equally apply to other hooks
like post-merge, I think.

Waiting to give a chance to reroll.

* rb/merge-prepare-commit-msg-hook:
  merge: drop unused arg from abort_commit method signature
  merge: make prepare_to_commit responsible for write_merge_state
  t7505: ensure cleanup after hook blocks merge
  t7505: add missing &&
Merge branch 'po/everyday-doc' into jch

This may make the said command to emit something, but the source is
not meant to be formatted into a manual pages to begin with, and
also its contents are a bit stale.  It may be a good first step in
the right direction, but needs more work to at least get the
mark-up right before public consumption.

* po/everyday-doc:
  Make 'git help everyday' work

# Conflicts:
# 	Documentation/Makefile
Merge branch 'jk/warn-on-object-refname-ambiguity' into jch

* jk/warn-on-object-refname-ambiguity:
  get_sha1: drop object/refname ambiguity flag
  get_sha1: speed up ambiguous 40-hex test
  FIXUP: teach DO_FOR_EACH_NO_RECURSE to prime_ref_dir()
  refs: teach for_each_ref a flag to avoid recursion
  cat-file: fix a minor memory leak in batch_objects
  cat-file: refactor error handling of batch_objects

# Conflicts:
# 	builtin/cat-file.c
Merge branch 'ks/diff-c-with-diff-order' into jch

Teach combine-diff to honour the path-output-order imposed by
diffcore-order.

* ks/diff-c-with-diff-order:
  combine-diff: combine_diff_path.len is not needed anymore
  combine-diff: Optimize combine_diff_path sets intersection
  diff test: Add tests for combine-diff with orderfile
  diffcore-order: Export generic ordering interface
Merge branch 'lt/request-pull' into jch

* lt/request-pull:
  pull-request: test updates
  Make request-pull able to take a refspec of form local:remote
  Make 'git request-pull' more strict about matching
Merge branch 'nd/submodule-pathspec-ending-with-slash' into jch

* nd/submodule-pathspec-ending-with-slash:
  clean: use cache_name_is_other()
  clean: replace match_pathspec() with dir_path_match()
  Pass directory indicator to match_pathspec_item()
  match_pathspec: match pathspec "foo/" against directory "foo"
  dir.c: prepare match_pathspec_item for taking more flags
  Rename match_pathspec_depth() to match_pathspec()
  Convert some match_pathspec_depth() to dir_path_match()
  Convert some match_pathspec_depth() to ce_path_match()

Conflicts:
	t/t4010-diff-pathspec.sh
Merge branch 'jk/color-for-more-pagers' into pu

'more' implementation of BSD wants to be told with MORE=R
environment before it shows colored output, while 'more' on some
other platforms will die when seeing MORE=R environment.

It appears that we are coming to the consensus that trying to be
too intimately knowledgeable about quirks of various pager
implementations on different platforms is a losing proposition, so
perhaps I should replace this with the alternative and simpler
approach I posted, unless there are strong objections.

* jk/color-for-more-pagers:
  pager: disable colors for some known-bad configurations
  DONOTMERGE: needs matching change to git-sh-setup
  setup_pager: set MORE=R
  setup_pager: refactor LESS/LV environment setting
Merge branch 'dk/blame-janitorial' into pu

* dk/blame-janitorial:
  Eliminate same_suspect function in builtin/blame.c
  builtin/blame.c: struct blame_entry does not need a prev link
Merge branch 'cc/interpret-trailers' into pu

* cc/interpret-trailers:
  Documentation: add documentation for 'git interpret-trailers'
  trailer: add tests for commands using env variables
  trailer: set author and committer env variables
  trailer: add tests for trailer command
  trailer: execute command from 'trailer.<name>.command'
  strbuf: add strbuf_replace()
  trailer: add new_trailer_item() function
  trailer: if no input file is passed, read from stdin
  trailer: add tests for "git interpret-trailers"
  trailer: add interpret-trailers command
  trailer: put all the processing together and print
  trailer: parse trailers from input file
  strbuf: add strbuf_isspace()
  trailer: process command line trailer arguments
  trailer: read and process config information
  trailer: process trailers from file and arguments
  Add data structures and basic functions for commit trailers