Commit graph

47736 commits

Author SHA1 Message Date
Stefan Beller b9cbfde6b1 diff.c: emit_diff_symbol learns DIFF_SYMBOL_NO_LF_EOF
Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-06-30 13:13:01 -07:00
Stefan Beller 68abc6f1c7 diff.c: emit_diff_symbol learns DIFF_SYMBOL_CONTEXT_FRAGINFO
Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-06-30 13:13:01 -07:00
Stefan Beller c64b420b4c diff.c: emit_diff_symbol learns DIFF_SYMBOL_CONTEXT_MARKER
Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-06-30 13:13:01 -07:00
Stefan Beller 36a4cefdf4 diff.c: introduce emit_diff_symbol
In a later patch we want to buffer all output before emitting it as a
new feature ("markup moved lines") conceptually cannot be implemented
in a single pass over the output.

There are different approaches to buffer all output such as:
* Buffering on the char level, i.e. we'd have a char[] which would
  grow at approximately 80 characters a line. This would keep the
  output completely unstructured, but might be very easy to implement,
  such as redirecting all output to a temporary file and working off
  that. The later passes over the buffer are quite complicated though,
  because we have to parse back any output and then decide if it should
  be modified.

* Buffer on a line level. As the output is mostly line oriented already,
  this would make sense, but it still is a bit awkward as we'd have to
  make sense of it again by looking at the first characters of a line
  to decide what part of a diff a line is.

* Buffer semantically. Imagine there is a formal grammar for the diff
  output and we'd keep the symbols of this grammar around. This keeps
  the highest level of structure in the buffered data, such that the
  actual memory requirements are less than say the first option. Instead
  of buffering the characters of the line, we'll buffer what we intend
  to do plus additional information for the specifics. An output of

    diff --git a/new.txt b/new.txt
    index fa69b07..412428c 100644
    Binary files a/new.txt and b/new.txt differ

  could be buffered as
     DIFF_SYMBOL_DIFF_START + new.txt
     DIFF_SYMBOL_INDEX_MODE + fa69b07 412428c "non-executable" flag
     DIFF_SYMBOL_BINARY_FILES + new.txt

This and the following patches introduce the third option of buffering
by first moving any output to emit_diff_symbol, and then introducing the
buffering in this function.

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-06-30 13:13:01 -07:00
Stefan Beller ec33150671 diff.c: factor out diff_flush_patch_all_file_pairs
In a later patch we want to do more things before and after all filepairs
are flushed. So factor flushing out all file pairs into its own function
that the new code can be plugged in easily.

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-06-30 13:13:01 -07:00
Stefan Beller dfb7728f63 diff.c: move line ending check into emit_hunk_header
The emit_hunk_header() function is responsible for assembling a
hunk header and calling emit_line() to send the hunk header
to the output file.  Its only caller fn_out_consume() needs
to prepare for a case where the function emits an incomplete
line and add the terminating LF.

Instead make sure emit_hunk_header() to always send a
completed line to emit_line().

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-06-30 13:13:01 -07:00
Stefan Beller f2d2a5def0 diff.c: readability fix
We already have dereferenced 'p->two' into a local variable 'two'.
Use that.

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-06-30 13:13:01 -07:00
Junio C Hamano 2cfb6cec94 Merge branch 'sb/hashmap-customize-comparison' into sb/diff-color-move
* sb/hashmap-customize-comparison: (566 commits)
  hashmap: migrate documentation from Documentation/technical into header
  patch-ids.c: use hashmap correctly
  hashmap.h: compare function has access to a data field
  Twelfth batch for 2.14
  Git 2.13.2
  Eleventh batch for 2.14
  Revert "split-index: add and use unshare_split_index()"
  Tenth batch for 2.14
  add--interactive: quote commentChar regex
  add--interactive: handle EOF in prompt_yesno
  auto-correct: tweak phrasing
  docs: update 64-bit core.packedGitLimit default
  t7508: fix a broken indentation
  grep: fix erroneously copy/pasted variable in check/assert pattern
  Ninth batch for 2.14
  glossary: define 'stash entry'
  status: add optional stash count information
  stash: update documentation to use 'stash entry'
  for_each_bisect_ref(): don't trim refnames
  mergetools/meld: improve compatibiilty with Meld on macOS X
  ...
2017-06-30 13:12:34 -07:00
Stefan Beller 1ecbf31d02 hashmap: migrate documentation from Documentation/technical into header
While at it, clarify the use of `key`, `keydata`, `entry_or_key` as well
as documenting the new data pointer for the compare function.

Rework the example.

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-06-30 13:11:59 -07:00
Stefan Beller 3da492f808 patch-ids.c: use hashmap correctly
As alluded to in the previous patch, the code in patch-ids.c is
using the hashmaps API wrong.

Luckily we do not have a bug, as all hashmap functionality that we use
here (hashmap_get) passes through the keydata.  If hashmap_get_next were
to be used, a bug would occur as that passes NULL for the key_data.

So instead use the hashmap API correctly and provide the caller required
data in the compare function via the first argument that always gets
passed and was setup via the hashmap_init function.

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-06-30 13:11:54 -07:00
Stefan Beller 7663cdc86c hashmap.h: compare function has access to a data field
When using the hashmap a common need is to have access to caller provided
data in the compare function. A couple of times we abuse the keydata field
to pass in the data needed. This happens for example in patch-ids.c.

This patch changes the function signature of the compare function
to have one more void pointer available. The pointer given for each
invocation of the compare function must be defined in the init function
of the hashmap and is just passed through.

Documentation of this new feature is deferred to a later patch.
This is a rather mechanical conversion, just adding the new pass-through
parameter.  However while at it improve the naming of the fields of all
compare functions used by hashmaps by ensuring unused parameters are
prefixed with 'unused_' and naming the parameters what they are (instead
of 'unused' make it 'unused_keydata').

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-06-30 12:49:28 -07:00
Junio C Hamano e0aaa1b653 Twelfth batch for 2.14
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-06-26 14:12:46 -07:00
Junio C Hamano aca226e6e9 Merge branch 'mb/reword-autocomplete-message'
Message update.

* mb/reword-autocomplete-message:
  auto-correct: tweak phrasing
2017-06-26 14:09:33 -07:00
Junio C Hamano 6968ca9b25 Merge branch 'ks/t7508-indent-fix'
Cosmetic update to a test.

* ks/t7508-indent-fix:
  t7508: fix a broken indentation
2017-06-26 14:09:32 -07:00
Junio C Hamano 54e6ce5960 Merge branch 'jk/add-p-commentchar-fix'
"git add -p" were updated in 2.12 timeframe to cope with custom
core.commentchar but the implementation was buggy and a
metacharacter like $ and * did not work.

* jk/add-p-commentchar-fix:
  add--interactive: quote commentChar regex
  add--interactive: handle EOF in prompt_yesno
2017-06-26 14:09:31 -07:00
Junio C Hamano e25a76721c Merge branch 'dt/raise-core-packed-git-limit'
Doc update for a topic already in 'master'.

* dt/raise-core-packed-git-limit:
  docs: update 64-bit core.packedGitLimit default
2017-06-26 14:09:30 -07:00
Junio C Hamano 5c83d850d0 Merge branch 'mh/packed-ref-store-prep'
Bugfix for a topic that is (only) in 'master'.

* mh/packed-ref-store-prep:
  for_each_bisect_ref(): don't trim refnames
  lock_packed_refs(): fix cache validity check
2017-06-26 14:09:29 -07:00
Junio C Hamano 849b44cdf1 Merge branch 'lb/status-stash-count'
"git status" learned to optionally give how many stash entries the
user has in its output.

* lb/status-stash-count:
  glossary: define 'stash entry'
  status: add optional stash count information
  stash: update documentation to use 'stash entry'
2017-06-26 14:09:29 -07:00
Junio C Hamano e629a7d28a Sync with 2.13.2
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-06-24 15:34:14 -07:00
Junio C Hamano 8c8e978f57 Git 2.13.2
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-06-24 15:31:36 -07:00
Junio C Hamano 8992def6b3 Merge branch 'sn/reset-doc-typofix' into maint
Doc update.

* sn/reset-doc-typofix:
  doc: git-reset: fix a trivial typo
2017-06-24 15:29:35 -07:00
Junio C Hamano 74567ac001 Merge branch 'sg/doc-pretty-formats' into maint
Doc update.

* sg/doc-pretty-formats:
  docs/pretty-formats: stress that %- removes all preceding line-feeds
2017-06-24 15:29:35 -07:00
Junio C Hamano 77bcac3e72 Merge branch 'sd/t3200-branch-m-test' into maint
New test.

* sd/t3200-branch-m-test:
  t3200: add test for single parameter passed to -m option
2017-06-24 15:29:34 -07:00
Junio C Hamano 8d7a6b6c85 Merge branch 'sg/revision-parser-skip-prefix' into maint
Code clean-up.

* sg/revision-parser-skip-prefix:
  revision.c: use skip_prefix() in handle_revision_pseudo_opt()
  revision.c: use skip_prefix() in handle_revision_opt()
  revision.c: stricter parsing of '--early-output'
  revision.c: stricter parsing of '--no-{min,max}-parents'
  revision.h: turn rev_info.early_output back into an unsigned int
2017-06-24 15:29:34 -07:00
Junio C Hamano 6f0c89d08c Merge branch 'km/test-mailinfo-b-failure' into maint
New tests.

* km/test-mailinfo-b-failure:
  t5100: add some more mailinfo tests
2017-06-24 15:29:33 -07:00
Junio C Hamano 4f7132a9be Merge branch 'sb/submodule-rm-absorb' into maint
Doc update to a recently graduated topic.

* sb/submodule-rm-absorb:
  Documentation/git-rm: correct submodule description
2017-06-24 15:29:32 -07:00
Junio C Hamano b960cd37c6 Merge branch 'jc/diff-tree-stale-comment' into maint
Comment fix.

* jc/diff-tree-stale-comment:
  diff-tree: update stale in-code comments
2017-06-24 15:29:31 -07:00
Junio C Hamano c4db75f275 Merge branch 'ps/stash-push-pathspec-fix' into maint
"git stash push <pathspec>" did not work from a subdirectory at all.
Bugfix for a topic in v2.13

* ps/stash-push-pathspec-fix:
  git-stash: fix pushing stash with pathspec from subdir
2017-06-24 15:29:30 -07:00
Junio C Hamano 0378c85644 Merge branch 'ls/github' into maint
Help contributors that visit us at GitHub.

* ls/github:
  Configure Git contribution guidelines for github.com
2017-06-24 15:29:29 -07:00
Junio C Hamano 7deb48af0f Merge branch 'jk/pack-idx-corruption-safety' into maint
A flaky test has been corrected.

* jk/pack-idx-corruption-safety:
  t5313: make extended-table test more deterministic
2017-06-24 15:29:29 -07:00
Junio C Hamano 7809876866 Merge branch 'jk/diff-blob' into maint
The result from "git diff" that compares two blobs, e.g. "git diff
$commit1:$path $commit2:$path", used to be shown with the full
object name as given on the command line, but it is more natural to
use the $path in the output and use it to look up .gitattributes.

* jk/diff-blob:
  diff: use blob path for blob/file diffs
  diff: use pending "path" if it is available
  diff: use the word "path" instead of "name" for blobs
  diff: pass whole pending entry in blobinfo
  handle_revision_arg: record paths for pending objects
  handle_revision_arg: record modes for "a..b" endpoints
  t4063: add tests of direct blob diffs
  get_sha1_with_context: dynamically allocate oc->path
  get_sha1_with_context: always initialize oc->symlink_path
  sha1_name: consistently refer to object_context as "oc"
  handle_revision_arg: add handle_dotdot() helper
  handle_revision_arg: hoist ".." check out of range parsing
  handle_revision_arg: stop using "dotdot" as a generic pointer
  handle_revision_arg: simplify commit reference lookups
  handle_revision_arg: reset "dotdot" consistently
2017-06-24 15:29:28 -07:00
Junio C Hamano e8d9d8b0bd Merge branch 'jc/name-rev-lw-tag' into maint
"git describe --contains" penalized light-weight tags so much that
they were almost never considered.  Instead, give them about the
same chance to be considered as an annotated tag that is the same
age as the underlying commit would.

* jc/name-rev-lw-tag:
  name-rev: favor describing with tags and use committer date to tiebreak
  name-rev: refactor logic to see if a new candidate is a better name
2017-06-24 15:29:28 -07:00
Junio C Hamano a2ba37c57b Eleventh batch for 2.14
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-06-24 14:34:11 -07:00
Junio C Hamano 50f03c6676 Merge branch 'ab/free-and-null'
A common pattern to free a piece of memory and assign NULL to the
pointer that used to point at it has been replaced with a new
FREE_AND_NULL() macro.

* ab/free-and-null:
  *.[ch] refactoring: make use of the FREE_AND_NULL() macro
  coccinelle: make use of the "expression" FREE_AND_NULL() rule
  coccinelle: add a rule to make "expression" code use FREE_AND_NULL()
  coccinelle: make use of the "type" FREE_AND_NULL() rule
  coccinelle: add a rule to make "type" code use FREE_AND_NULL()
  git-compat-util: add a FREE_AND_NULL() wrapper around free(ptr); ptr = NULL
2017-06-24 14:28:41 -07:00
Junio C Hamano cda4ba30b1 Merge branch 'jk/warn-add-gitlink'
Using "git add d/i/r" when d/i/r is the top of the working tree of
a separate repository would create a gitlink in the index, which
would appear as a not-quite-initialized submodule to others.  We
learned to give warnings when this happens.

* jk/warn-add-gitlink:
  t: move "git add submodule" into test blocks
  add: warn when adding an embedded repository
2017-06-24 14:28:41 -07:00
Junio C Hamano f31d23a399 Merge branch 'bw/config-h'
Fix configuration codepath to pay proper attention to commondir
that is used in multi-worktree situation, and isolate config API
into its own header file.

* bw/config-h:
  config: don't implicitly use gitdir or commondir
  config: respect commondir
  setup: teach discover_git_directory to respect the commondir
  config: don't include config.h by default
  config: remove git_config_iter
  config: create config.h
2017-06-24 14:28:41 -07:00
Junio C Hamano 5812b3f73b Merge branch 'bw/ls-files-sans-the-index'
Code clean-up.

* bw/ls-files-sans-the-index:
  ls-files: factor out tag calculation
  ls-files: factor out debug info into a function
  ls-files: convert show_files to take an index
  ls-files: convert show_ce_entry to take an index
  ls-files: convert prune_cache to take an index
  ls-files: convert ce_excluded to take an index
  ls-files: convert show_ru_info to take an index
  ls-files: convert show_other_files to take an index
  ls-files: convert show_killed_files to take an index
  ls-files: convert write_eolinfo to take an index
  ls-files: convert overlay_tree_on_cache to take an index
  tree: convert read_tree to take an index parameter
  convert: convert renormalize_buffer to take an index
  convert: convert convert_to_git to take an index
  convert: convert convert_to_git_filter_fd to take an index
  convert: convert crlf_to_git to take an index
  convert: convert get_cached_convert_stats_ascii to take an index
2017-06-24 14:28:40 -07:00
Junio C Hamano 1c3d87cf55 Merge branch 'js/alias-early-config'
The code to pick up and execute command alias definition from the
configuration used to switch to the top of the working tree and
then come back when the expanded alias was executed, which was
unnecessarilyl complex.  Attempt to simplify the logic by using the
early-config mechanism that does not chdir around.

* js/alias-early-config:
  alias: use the early config machinery to expand aliases
  t7006: demonstrate a problem with aliases in subdirectories
  t1308: relax the test verifying that empty alias values are disallowed
  help: use early config when autocorrecting aliases
  config: report correct line number upon error
  discover_git_directory(): avoid setting invalid git_dir
2017-06-24 14:28:40 -07:00
Junio C Hamano 9bca0e5513 Merge branch 'sn/reset-doc-typofix'
Doc update.

* sn/reset-doc-typofix:
  doc: git-reset: fix a trivial typo
2017-06-24 14:28:39 -07:00
Junio C Hamano f3c9c8501d Merge branch 'sg/doc-pretty-formats'
Doc update.

* sg/doc-pretty-formats:
  docs/pretty-formats: stress that %- removes all preceding line-feeds
2017-06-24 14:28:39 -07:00
Junio C Hamano 8af3c643d9 Merge branch 'rs/pretty-add-again'
The pretty-format specifiers like '%h', '%t', etc. had an
optimization that no longer works correctly.  In preparation/hope
of getting it correctly implemented, first discard the optimization
that is broken.

* rs/pretty-add-again:
  pretty: recalculate duplicate short hashes
2017-06-24 14:28:38 -07:00
Junio C Hamano ef9402366c Merge branch 'jk/diff-highlight-module'
The 'diff-highlight' program (in contrib/) has been restructured
for easier reuse by an external project 'diff-so-fancy'.

* jk/diff-highlight-module:
  diff-highlight: split code into module
2017-06-24 14:28:37 -07:00
Junio C Hamano 2bc81f2a83 Merge branch 'ah/doc-gitattributes-empty-index'
An example in documentation that does not work in multi worktree
configuration has been corrected.

* ah/doc-gitattributes-empty-index:
  doc: do not use `rm .git/index` when normalizing line endings
2017-06-24 14:28:37 -07:00
Junio C Hamano 5fd73da391 Merge branch 'ab/wildmatch-glob-slash-test'
A new test to show the interaction between the pattern [^a-z]
(which matches '/') and a slash in a path has been added.  The
pattern should not match the slash with "pathmatch", but should
with "wildmatch".

* ab/wildmatch-glob-slash-test:
  wildmatch test: cover a blind spot in "/" matching
2017-06-24 14:28:37 -07:00
Junio C Hamano 2f4af84578 Merge branch 'ab/pcre-v2'
Hotfix for a topic already in 'master'.

* ab/pcre-v2:
  grep: fix erroneously copy/pasted variable in check/assert pattern
2017-06-24 14:28:36 -07:00
Junio C Hamano 6bbd512374 Merge branch 'da/mergetools-meld-output-opt-on-macos'
"git mergetool" learned to work around a wrapper MacOS X adds
around underlying meld.

* da/mergetools-meld-output-opt-on-macos:
  mergetools/meld: improve compatibiilty with Meld on macOS X
2017-06-24 14:28:36 -07:00
Junio C Hamano 6ba4d62ba8 Merge branch 'nd/split-index-unshare'
* nd/split-index-unshare:
  Revert "split-index: add and use unshare_split_index()"
2017-06-24 12:04:25 -07:00
Junio C Hamano 64719b115d Revert "split-index: add and use unshare_split_index()"
This reverts commit f9d7abec2ad2f9eb3d8873169cc28c34273df082;
see public-inbox.org/git/CAP8UFD0bOfzY-_hBDKddOcJdPUpP2KEVaX_SrCgvAMYAHtseiQ@mail.gmail.com
2017-06-24 12:02:39 -07:00
Junio C Hamano 5402b1352f Tenth batch for 2.14
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-06-22 14:18:05 -07:00
Junio C Hamano 9eafe86d58 Merge branch 'rs/strbuf-addftime-zZ'
As there is no portable way to pass timezone information to
strftime, some output format from "git log" and friends are
impossible to produce.  Teach our own strbuf_addftime to replace %z
and %Z with caller-supplied values to help working around this.

* rs/strbuf-addftime-zZ:
  date: use localtime() for "-local" time formats
  t0006: check --date=format zone offsets
  strbuf: let strbuf_addftime handle %z and %Z itself
2017-06-22 14:15:25 -07:00