summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2016-02-08rerere: split conflict ID furtherJunio C Hamano
The plan is to keep assigning the backward compatible conflict ID based on the hash of the (normalized) text of conflicts, keep using that conflict ID as the directory name under $GIT_DIR/rr-cache/, but allow each conflicted path to use a separate "variant" to record resolutions, i.e. having more than one <preimage,postimage> pairs under $GIT_DIR/rr-cache/$ID/ directory. As the first step in that direction, separate the shared "conflict ID" out of the rerere_id structure. The plan is to keep information per $ID in rerere_dir, that can be shared among rerere_id that is per conflicted path. When we are done with rerere(), which can be directly called from other programs like "git apply", "git commit" and "git merge", the shared rerere_dir structures can be freed entirely, so they are not reference-counted and they are not freed when we release rerere_id's that reference them. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-02-08rerere: replace strcpy with xsnprintfJeff King
This shouldn't overflow, as we are copying a sha1 hex into a 41-byte buffer. But it does not hurt to use a bound-checking function, which protects us and makes auditing for overflows easier. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-07-24rerere: un-nest merge() furtherJunio C Hamano
By consistently using "upon failure, set 'ret' and jump to out" pattern, flatten the function further. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-07-24rerere: use "struct rerere_id" instead of "char *" for conflict IDJunio C Hamano
This gives a thin abstraction between the conflict ID that is a hash value obtained by inspecting the conflicts and the name of the directory under $GIT_DIR/rr-cache/, in which the previous resolution is recorded to be replayed. The plan is to make sure that the presence of the directory does not imply the presense of a previous resolution and vice-versa, and later allow us to have more than one pair of <preimage, postimage> for a given conflict ID. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-07-24rerere: call conflict-ids IDsJunio C Hamano
Most places we call conflict IDs "name" and some others we call them "hex"; update all of them to "id". Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-07-24rerere: further clarify do_rerere_one_path()Junio C Hamano
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-07-24rerere: further de-dent do_plain_rerere()Junio C Hamano
It's just easier to follow this way. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-07-24rerere: refactor "replay" part of do_plain_rerere()Junio C Hamano
Extract the body of a loop that attempts to replay recorded resolution for each conflicted path into a helper function, not because I want to call it from multiple places later, but because the logic has become too deeply nested and hard to read. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-07-24rerere: explain the remainderJunio C Hamano
Explain the internals of rerere as in-code comments, while sprinkling "NEEDSWORK" comment to highlight iffy bits and questionable assumptions. This covers the codepath that implements "rerere gc" and "rerere clear". Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-07-24rerere: explain "rerere forget" codepathJunio C Hamano
Explain the internals of rerere as in-code comments, while sprinkling "NEEDSWORK" comment to highlight iffy bits and questionable assumptions. This covers the codepath that implements "rerere forget". Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-07-24rerere: explain the primary codepathJunio C Hamano
Explain the internals of rerere as in-code comments, while sprinkling "NEEDSWORK" comment to highlight iffy bits and questionable assumptions. This one covers the codepath reached from rerere(), the primary interface to the subsystem. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-07-24rerere: explain MERGE_RR management helpersJunio C Hamano
Explain the internals of rerere as in-code comments, while sprinkling "NEEDSWORK" comment to highlight iffy bits and questionable assumptions. This one covers the "$GIT_DIR/MERGE_RR" file and in-core merge_rr that are used to keep track of the status of "rerere" session in progress. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-07-24rerere: fix benign off-by-one non-bug and clarify codeJunio C Hamano
rerere_io_putconflict() wants to use a limited fixed-sized buf[] on stack repeatedly to formulate a longer string, but its implementation is doubly confusing: * When it knows that the whole thing fits in buf[], it wants to fill early part of buf[] with conflict marker characters, followed by a LF and a NUL. It miscounts the size of the buffer by 1 and does not use the last byte of buf[]. * When it needs to show only the early part of a long conflict marker string (because the whole thing does not fit in buf[]), it adjusts the number of bytes shown in the current round in a strange-looking way. It makes sure that this round does not emit all bytes and leaves at least one byte to the next round, so that "it all fits" case will pick up the rest and show the terminating LF. While this is correct, one needs to stop and think for a while to realize why it is correct without an explanation. Fix the benign off-by-one, and add comments to explain the strange-looking size adjustment. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-07-24rerere: explain the rerere I/O abstractionJunio C Hamano
Explain the internals of rerere as in-code comments. This one covers our thin I/O abstraction to read from either a file or a memory while optionally writing out to a file. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-07-24rerere: do not leak mmfile[] for a path with multiple stage #1 entriesJunio C Hamano
A conflicted index can have multiple stage #1 entries when dealing with a criss-cross merge and using the "resolve" merge strategy. Plug the leak by reading only the first one of the same stage entries. Strictly speaking, this fix does change the semantics, in that we used to use the last stage #1 entry as the common ancestor when doing the plain-vanilla three-way merge, but with the leak fix, we will use the first stage #1 entry. But it is not a grave backward compatibility breakage. Either way, we are arbitrarily picking one of multiple stage #1 entries and using it, ignoring others, and there is no meaning in the ordering of these stage #1 entries. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-07-24rerere: stop looping unnecessarilyJunio C Hamano
handle_cache() loops 3 times starting from an index entry that is unmerged, while ignoring an entry for a path that is different from what we are looking for. As the index is sorted, once we see a different path, we know we saw all stages for the path we are interested in. Just loop while we see the same path and then break, instead of continuing for 3 times. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-07-24rerere: drop want_sp parameter from is_cmarker()Junio C Hamano
As the nature of the conflict marker line determines if there should be a SP and label after it, the caller shouldn't have to pass the parameter redundantly. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-07-24rerere: report autoupdated paths only after actually updating themJunio C Hamano
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-07-24rerere: write out each record of MERGE_RR in one goJunio C Hamano
Instead of writing the hash for a conflict, a HT, and the path with three separate write_in_full() calls, format them into a single record into a strbuf and write it out in one go. As a more recent "rerere remaining" codepath abuses the .util field of the merge_rr data to store a sentinel token, make sure that codepath does not call into this function (of course, "remaining" is a read-only operation and currently does not call it). Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-07-24rerere: lift PATH_MAX limitationJunio C Hamano
The MERGE_RR file records a collection of NUL-terminated entries, each of which consists of - a hash that identifies the conflict - a HT - the pathname We used to read this piece-by-piece, and worse yet, read the pathname part a byte at a time into a fixed buffer of size PATH_MAX. Instead, read a whole entry using strbuf_getwholeline() and parse out the fields. This way, we issue fewer read(2) calls and more importantly we do not have to limit the pathname to PATH_MAX. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-07-24rerere: plug conflict ID leaksJunio C Hamano
The merge_rr string list stores the conflict ID (a hexadecimal string that is used to index into $GIT_DIR/rr-cache) in the .util field of its elements, and when do_plain_rerere() resolves a conflict, the field is cleared. Also, when rerere_forget() recomputes the conflict ID to updates the preimage file, the conflict ID for the path is updated. We forgot to free the existing conflict ID when we did these two operations. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-07-24rerere: handle conflicts with multiple stage #1 entriesJunio C Hamano
A conflicted index can have multiple stage #1 entries when dealing with a criss-cross merge and using the "resolve" merge strategy. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-06-28rerere: fix an off-by-one non-bugJunio C Hamano
When ac49f5ca (rerere "remaining", 2011-02-16) split out a new helper function check_one_conflict() out of find_conflict() function, so that the latter will use the returned value from the new helper to update the loop control variable that is an index into active_cache[], the new variable incremented the index by one too many when it found a path with only stage #1 entry at the very end of active_cache[]. This "strange" return value does not have any effect on the loop control of two callers of this function, as they all notice that active_nr+2 is larger than active_nr just like active_nr+1 is, but nevertheless it puzzles the readers when they are trying to figure out what the function is trying to do. In fact, there is no need to do an early return. The code that follows after skipping the stage #1 entry is fully prepared to handle a case where the entry is at the very end of active_cache[]. Help future readers from unnecessary confusion by dropping an early return. We skip the stage #1 entry, and if there are stage #2 and stage #3 entries for the same path, we diagnose the path as THREE_STAGED (otherwise we say PUNTED), and then we skip all entries for the same path. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-05-11Git 2.3.8v2.3.8Junio C Hamano
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-05-11Merge branch 'mm/usage-log-l-can-take-regex' into maint-2.3Junio C Hamano
Documentation fix. * mm/usage-log-l-can-take-regex: log -L: improve error message on malformed argument Documentation: change -L:<regex> to -L:<funcname>
2015-05-11Merge branch 'jc/diff-no-index-d-f' into maint-2.3Junio C Hamano
The usual "git diff" when seeing a file turning into a directory showed a patchset to remove the file and create all files in the directory, but "git diff --no-index" simply refused to work. Also, when asked to compare a file and a directory, imitate POSIX "diff" and compare the file with the file with the same name in the directory, instead of refusing to run. * jc/diff-no-index-d-f: diff-no-index: align D/F handling with that of normal Git diff-no-index: DWIM "diff D F" into "diff D/F F"
2015-05-11Merge branch 'oh/fix-config-default-user-name-section' into maint-2.3Junio C Hamano
The default $HOME/.gitconfig file created upon "git config --global" that edits it had incorrectly spelled user.name and user.email entries in it. * oh/fix-config-default-user-name-section: config: fix settings in default_user_config template
2015-05-11Merge branch 'jc/epochtime-wo-tz' into maint-2.3Junio C Hamano
"git commit --date=now" or anything that relies on approxidate lost the daylight-saving-time offset. * jc/epochtime-wo-tz: parse_date_basic(): let the system handle DST conversion parse_date_basic(): return early when given a bogus timestamp
2015-04-27Git 2.3.7v2.3.7Junio C Hamano
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-04-27Merge branch 'tb/connect-ipv6-parse-fix' into maintJunio C Hamano
An earlier update to the parser that disects a URL broke an address, followed by a colon, followed by an empty string (instead of the port number), e.g. ssh://example.com:/path/to/repo. * tb/connect-ipv6-parse-fix: connect.c: ignore extra colon after hostname
2015-04-27Merge branch 'ma/bash-completion-leaking-x' into maintJunio C Hamano
The completion script (in contrib/) contaminated global namespace and clobbered on a shell variable $x. * ma/bash-completion-leaking-x: completion: fix global bash variable leak on __gitcompappend
2015-04-27Merge branch 'jc/push-cert' into maintJunio C Hamano
The "git push --signed" protocol extension did not limit what the "nonce" that is a server-chosen string can contain or how long it can be, which was unnecessarily lax. Limit both the length and the alphabet to a reasonably small space that can still have enough entropy. * jc/push-cert: push --signed: tighten what the receiving end can ask to sign
2015-04-21Git 2.3.6v2.3.6Junio C Hamano
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-04-21Merge branch 'jk/colors' into maintJunio C Hamano
"diff-highlight" (in contrib/) used to show byte-by-byte differences, which meant that multi-byte characters can be chopped in the middle. It learned to pay attention to character boundaries (assuming the UTF-8 payload). * jk/colors: diff-highlight: do not split multibyte characters
2015-04-21Merge branch 'jk/test-annoyances' into maintJunio C Hamano
Test fixes. * jk/test-annoyances: t5551: make EXPENSIVE test cheaper t5541: move run_with_cmdline_limit to test-lib.sh t: pass GIT_TRACE through Apache t: redirect stderr GIT_TRACE to descriptor 4 t: translate SIGINT to an exit
2015-04-21Merge branch 'pt/enter-repo-comment-fix' into maintJunio C Hamano
Documentation update. * pt/enter-repo-comment-fix: enter_repo(): fix docs to match code
2015-04-21Merge branch 'jz/gitweb-conf-doc-fix' into maintJunio C Hamano
Documentation update. * jz/gitweb-conf-doc-fix: gitweb.conf.txt: say "build-time", not "built-time"
2015-04-21Merge branch 'jk/cherry-pick-docfix' into maintJunio C Hamano
* jk/cherry-pick-docfix: cherry-pick: fix docs describing handling of empty commits
2015-04-21Merge branch 'iu/fix-parse-options-h-comment' into maintJunio C Hamano
* iu/fix-parse-options-h-comment: parse-options.h: OPTION_{BIT,SET_INT} do not store pointer to defval
2015-04-21Merge branch 'jg/cguide-we-cannot-count' into maintJunio C Hamano
* jg/cguide-we-cannot-count: CodingGuidelines: update 'rough' rule count
2015-04-21Merge branch 'jk/pack-corruption-post-mortem' into maintJunio C Hamano
Documentation update. * jk/pack-corruption-post-mortem: howto: document more tools for recovery corruption
2015-04-21Merge branch 'jn/doc-fast-import-no-16-octopus-limit' into maintJunio C Hamano
Documentation update. * jn/doc-fast-import-no-16-octopus-limit: fast-import doc: remove suggested 16-parent limit
2015-04-20log -L: improve error message on malformed argumentMatthieu Moy
The old message did not mention the :regex:file form. To avoid overly long lines, split the message into two lines (in case item->string is long, it will be the only part truncated in a narrow terminal). Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-04-20Documentation: change -L:<regex> to -L:<funcname>Matthieu Moy
The old wording was somehow implying that <start> and <end> were not regular expressions. Also, the common case is to use a plain function name here so <funcname> makes sense (the fact that it is a regular expression is documented in line-range-format.txt). Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-04-17config: fix settings in default_user_config templateOssi Herrala
The name (not user) and email setting should be in config section "user" and not in "core" as documented in Documentation/config.txt. Signed-off-by: Ossi Herrala <oherrala@gmail.com> Reviewed-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-04-15parse_date_basic(): let the system handle DST conversionJunio C Hamano
The function parses the input to compute the broken-down time in "struct tm", and the GMT timezone offset. If the timezone offset does not exist in the input, the broken-down time is turned into the number of seconds since epoch both in the current timezone and in GMT and the offset is computed as their difference. However, we forgot to make sure tm.tm_isdst is set to -1 (i.e. let the system figure out if DST is in effect in the current timezone when turning the broken-down time to the number of seconds since epoch); it is done so at the beginning of the function, but a call to match_digit() in the function can lead to a call to gmtime_r() to clobber the field. Reported-by: Linus Torvalds <torvalds@linux-foundation.org> Diagnosed-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-04-15parse_date_basic(): return early when given a bogus timestampJunio C Hamano
When the input does not have GMT timezone offset, the code computes it by computing the local and GMT time for the given timestamp. But there is no point doing so if the given timestamp is known to be a bogus one. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-04-14CodingGuidelines: update 'rough' rule countJulian Gindi
Changed inaccurate count of "rough rules" from three to the more generic 'a few'. Signed-off-by: Julian Gindi <juliangindi@gmail.com> Reviewed-by: Eric Sunshine <sunshine@sunshineco.com> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-04-13completion: fix global bash variable leak on __gitcompappendMárcio Almada
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-04-09connect.c: ignore extra colon after hostnameTorsten Bögershausen
Ignore an extra ':' at the end of the hostname in URL's like "ssh://example.com:/path/to/repo" The colon is meant to separate a port number from the hostname. If the port is empty, the colon should be ignored, see RFC 3986. It had been working for URLs with ssh:// scheme, but was unintentionally broken in 86ceb3, "allow ssh://user@[2001:db8::1]/repo.git" Reported-by: Reid Woodbury Jr. <reidw@rawsound.com> Signed-off-by: Torsten Bögershausen <tboegi@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>