summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* t1402-check-ref-format: skip tests of refs beginning with slash on WindowsJohannes Sixt2011-10-131-36/+52
| | | | | | | | | | | | | | Bash on Windows converts program arguments that look like absolute POSIX paths to their Windows form, i.e., drive-letter-colon format. For this reason, those tests in t1402 that check refs that begin with a slash do not work as expected on Windows: valid_ref tests are doomed to fail, and invalid_ref tests fail for the wrong reason (that there is a colon rather than that they begin with a slash). Skip these tests. Signed-off-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* add_ref(): verify that the refname is formatted correctlyMichael Haggerty2011-10-052-5/+19
| | | | | | | | | | | | In add_ref(), verify that the refname is formatted correctly before adding it to the ref_list. Here we have to allow refname components that start with ".", since (for example) the remote protocol uses synthetic reference name ".have". So add a new REFNAME_DOT_COMPONENT flag that can be passed to check_refname_format() to allow leading dots. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* resolve_ref(): expand documentationMichael Haggerty2011-10-052-13/+33
| | | | | | | | Record information about resolve_ref(), hard-won via reverse engineering, in a comment for future spelunkers. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* resolve_ref(): also treat a too-long SHA1 as invalidMichael Haggerty2011-10-051-1/+2
| | | | | | | | If the SHA1 in a reference file is not terminated by a space or end-of-file, consider it malformed and emit a warning. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* resolve_ref(): emit warnings for improperly-formatted referencesMichael Haggerty2011-10-051-2/+4
| | | | | | | | | While resolving references, if a reference is found that is in an unrecognized format, emit a warning (and then fail, as before). Wouldn't *you* want to know? Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* resolve_ref(): verify that the input refname has the right formatMichael Haggerty2011-10-051-0/+3
| | | | | Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* remote: avoid passing NULL to read_ref()Michael Haggerty2011-10-051-2/+4
| | | | | | | | | | read_ref() can (and in test t5800, actually *does*) return NULL. Don't pass the NULL along to read_ref(). Coincidentally, this mistake didn't make resolve_ref() blow up, but upcoming changes to resolve_ref() will make it less forgiving. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* remote: use xstrdup() instead of strdup()Michael Haggerty2011-10-052-3/+3
| | | | | Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* resolve_ref(): do not follow incorrectly-formatted symbolic refsMichael Haggerty2011-10-051-0/+5
| | | | | | | | Emit a warning and fail if a symbolic reference refers to an incorrectly-formatted refname. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* resolve_ref(): extract a function get_packed_ref()Michael Haggerty2011-10-051-13/+34
| | | | | | | | | Making it a function and giving it a name makes the code clearer. I also have a strong suspicion that the function will find other uses in the future. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* resolve_ref(): turn buffer into a proper string as soon as possibleMichael Haggerty2011-10-051-10/+10
| | | | | | | | | | | Immediately strip off trailing spaces and null-terminate the string holding the contents of the reference file; this allows the use of string functions and avoids the need to keep separate track of the string's length. (get_sha1_hex() fails automatically if the string is too short.) Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* resolve_ref(): only follow a symlink that contains a valid, normalized refnameMichael Haggerty2011-10-051-1/+2
| | | | | Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* resolve_ref(): use prefixcmp()Michael Haggerty2011-10-051-2/+2
| | | | | | | | Terminate the link content string one step earlier, allowing prefixcmp() to be used instead of the less clear memcmp(). Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* resolve_ref(): explicitly fail if a symlink is not readableMichael Haggerty2011-10-051-0/+2
| | | | | | | | | Previously the failure came later, after a few steps in which the length was treated like the actual length of a string. Even though the old code gave the same answers, it was somewhat misleading. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Change check_refname_format() to reject unnormalized refnamesMichael Haggerty2011-10-055-28/+49
| | | | | | | | | | | | | | Since much of the infrastructure does not work correctly with unnormalized refnames, change check_refname_format() to reject them. Similarly, change "git check-ref-format" to reject unnormalized refnames by default. But add an option --normalize, which causes "git check-ref-format" to normalize the refname before checking its format, and print the normalized refname. This is exactly the behavior of the old --print option, which is retained but deprecated. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Inline function refname_format_print()Michael Haggerty2011-10-051-9/+7
| | | | | | | Soon we will make printing independent of collapsing. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Make collapse_slashes() allocate memory for its resultMichael Haggerty2011-10-051-9/+10
| | | | | | | This will make upcoming changes a tiny bit easier. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Do not allow ".lock" at the end of any refname componentMichael Haggerty2011-10-053-9/+7
| | | | | | | | | | | | | | Allowing any refname component to end with ".lock" is looking for trouble; for example, $ git br foo.lock/bar $ git br foo fatal: Unable to create '[...]/.git/refs/heads/foo.lock': File exists. Therefore, do not allow any refname component to end with ".lock". Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Refactor check_refname_format()Michael Haggerty2011-10-051-40/+55
| | | | | | | Among other things, extract a function check_refname_component(). Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Change check_ref_format() to take a flags argumentMichael Haggerty2011-10-0520-126/+69
| | | | | | | | | | | | | | | Change check_ref_format() to take a flags argument that indicates what is acceptable in the reference name (analogous to "git check-ref-format"'s "--allow-onelevel" and "--refspec-pattern"). This is more convenient for callers and also fixes a failure in the test suite (and likely elsewhere in the code) by enabling "onelevel" and "refspec-pattern" to be allowed independently of each other. Also rename check_ref_format() to check_refname_format() to make it obvious that it deals with refnames rather than references themselves. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Change bad_ref_char() to return a boolean valueMichael Haggerty2011-10-051-9/+6
| | | | | | | | | | | | | | | Previously most bad characters were indicated by returning 1, but "*" was special-cased to return 2 instead of 1. One caller examined the return value to see whether the special case occurred. But it is easier (to document and understand) for bad_ref_char() simply to return a boolean value, treating "*" like any other bad character. Special-case the handling of "*" (which only occurs in very specific circumstances) at the caller. The resulting calling code thereby also becomes more transparent. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* git check-ref-format: add options --allow-onelevel and --refspec-patternMichael Haggerty2011-10-053-21/+152
| | | | | | | | | | | | | | | | | | | Also add tests of the new options. (Actually, one big reason to add the new options is to make it easy to test check_ref_format(), though the options should also be useful to other scripts.) Interpret the result of check_ref_format() based on which types of refnames are allowed. However, because check_ref_format() can only return a single value, one test case is still broken. Specifically, the case "git check-ref-format --onelevel '*'" incorrectly succeeds because check_ref_format() returns CHECK_REF_FORMAT_ONELEVEL for this refname even though the refname is also CHECK_REF_FORMAT_WILDCARD. The type of check that leads to this failure is used elsewhere in "real" code and could lead to bugs; it will be fixed over the next few commits. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* t1402: add some more testsMichael Haggerty2011-10-051-0/+9
| | | | | | | | The new tests reflect the status quo. Soon the rule for "*.lock" in refname components will be tightened up. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* get_sha1_hex(): do not read past a NUL characterMichael Haggerty2011-10-052-1/+18
| | | | | | | | | | | | | | | | Previously, get_sha1_hex() would read one character past the end of a null-terminated string whose strlen was an even number less than 40. Although the function correctly returned -1 in these cases, the extra memory access might have been to uninitialized (or even, conceivably, unallocated) memory. Add a check to avoid reading past the end of a string. This problem was discovered by Thomas Rast <trast@student.ethz.ch> using valgrind. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* RelNotes/1.7.7: minor fixesMichael J Gruber2011-09-071-26/+26
| | | | | Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Minor update to how-to maintain gitJunio C Hamano2011-09-071-7/+6
| | | | | | | | A few more parts of this document is stale that needs updating to reflect the reality, but I do not regularly rebase topics that are only in "pu" anymore, which may be noteworthy for a commit. Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Update draft release notes to 1.7.7Junio C Hamano2011-09-061-1/+6
| | | | Signed-off-by: Junio C Hamano <gitster@pobox.com>
* Merge branch 'rc/histogram-diff'Junio C Hamano2011-09-061-0/+2
|\ | | | | | | | | * rc/histogram-diff: xdiff/xprepare: initialise xdlclassifier_t cf in xdl_prepare_env()
| * xdiff/xprepare: initialise xdlclassifier_t cf in xdl_prepare_env()Tay Ray Chuan2011-08-311-0/+2
| | | | | | | | | | | | | | | | | | | | Ensure that the xdl_free_classifier() call on xdlclassifier_t cf is safe even if xdl_init_classifier() isn't called. This may occur in the case where diff is run with --histogram and a call to, say, xdl_prepare_ctx() fails. Signed-off-by: Tay Ray Chuan <rctay89@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | Merge branch 'cb/maint-ls-files-error-report'Junio C Hamano2011-09-061-10/+12
|\ \ | | | | | | | | | | | | * cb/maint-ls-files-error-report: t3005: do not assume a particular order of stdout and stderr of git-ls-files
| * | t3005: do not assume a particular order of stdout and stderr of git-ls-filesJohannes Sixt2011-08-281-10/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | There is no guarantee that stderr is flushed before stdout when both channels are redirected to a file. Check the channels using independent files. Signed-off-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | | Merge branch 'mh/check-ref-format-print-normalize'Junio C Hamano2011-09-063-4/+13
|\ \ \ | | | | | | | | | | | | | | | | | | | | * mh/check-ref-format-print-normalize: Forbid DEL characters in reference names check-ref-format --print: Normalize refnames that start with slashes
| * | | Forbid DEL characters in reference namesMichael Haggerty2011-08-272-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | DEL is an ASCII control character and therefore should not be permitted in reference names. Add tests for this and other unusual characters. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | | check-ref-format --print: Normalize refnames that start with slashesMichael Haggerty2011-08-252-3/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When asked if "refs///heads/master" is valid, check-ref-format says "Yes, it is well formed", and when asked to print canonical form, it shows "refs/heads/master". This is so that it can be tucked after "$GIT_DIR/" to form a valid pathname for a loose ref, and we normalize a pathname like "$GIT_DIR/refs///heads/master" to de-dup the slashes in it. Similarly, when asked if "/refs/heads/master" is valid, check-ref-format says "Yes, it is Ok", but the leading slash is not removed when printing, leading to "$GIT_DIR//refs/heads/master". Fix it to make sure such leading slashes are removed. Add tests that such refnames are accepted and normalized correctly. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | | | Sync with 1.7.6.2Junio C Hamano2011-09-068-41/+21
|\ \ \ \ | | | | | | | | | | | | | | | Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | | | Git 1.7.6.2v1.7.6.2Junio C Hamano2011-09-064-4/+13
| | | | | | | | | | | | | | | | | | | | Signed-off-by: Junio C Hamano <gitster@pobox.com>
| * | | | Revert "Merge branch 'cb/maint-quiet-push' into maint"Junio C Hamano2011-09-066-39/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit ffa69e61d3c5730bd4b65a465efc130b0ef3c7df, reversing changes made to 4a13c4d14841343d7caad6ed41a152fee550261d. Adding a new command line option to receive-pack and feed it from send-pack is not an acceptable way to add features, as there is no guarantee that your updated send-pack will be talking to updated receive-pack. New features need to be added via the capability mechanism negotiated over the protocol. Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | | | | Update draft release notes to 1.7.7Junio C Hamano2011-09-021-2/+10
| | | | | | | | | | | | | | | | | | | | Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | | | | Merge branch 'js/i18n-scripts-2'Junio C Hamano2011-09-021-35/+14
|\ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | * js/i18n-scripts-2: bisect: take advantage of gettextln, eval_gettextln.
| * | | | | bisect: take advantage of gettextln, eval_gettextln.Jon Seymour2011-08-301-35/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Signed-off-by: Jon Seymour <jon.seymour@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | | | | | Merge branch 'tr/maint-t3903-misquoted-command'Junio C Hamano2011-09-021-1/+1
|\ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | * tr/maint-t3903-misquoted-command: t3903: fix misquoted rev-parse invocation
| * | | | | | t3903: fix misquoted rev-parse invocationThomas Rast2011-08-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | !"git ..." hopefully always succeeds because "git ..." is not the name of any executable. However, that's not what was intended. Unquote it, and while we're at it, also replace ! with test_must_fail since it is a call to git. Signed-off-by: Thomas Rast <trast@student.ethz.ch> Acked-by: Jon Seymour <jon.seymour@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | | | | | | Merge branch 'bc/bisect-test-use-shell-path'Junio C Hamano2011-09-021-1/+1
|\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * bc/bisect-test-use-shell-path: t6030: use $SHELL_PATH to invoke user's preferred shell instead of bare sh
| * | | | | | | t6030: use $SHELL_PATH to invoke user's preferred shell instead of bare shBrandon Casey2011-08-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some platforms (IRIX, Solaris) provide an ancient /bin/sh which chokes on modern shell syntax like $(). SHELL_PATH is provided to allow the user to specify a working sh, let's use it here. Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | | | | | | | Merge branch 'va/p4-branch-import-test-update'Junio C Hamano2011-09-021-11/+8
|\ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * va/p4-branch-import-test-update: git-p4: simple branch tests edits
| * | | | | | | | git-p4: simple branch tests editsPete Wyckoff2011-08-291-11/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | More review comments. Signed-off-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Vitor Antunes <vitor.hda@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | | | | | | | | Merge branch 'tr/maint-strbuf-grow-nul-termination'Junio C Hamano2011-09-021-4/+5
|\ \ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * tr/maint-strbuf-grow-nul-termination: strbuf_grow(): maintain nul-termination even for new buffer
| * | | | | | | | | strbuf_grow(): maintain nul-termination even for new bufferThomas Rast2011-08-291-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In the case where sb is initialized to the slopbuf (through strbuf_init(sb,0) or STRBUF_INIT), strbuf_grow() loses the terminating nul: it grows the buffer, but gives ALLOC_GROW a NULL source to avoid it being freed. So ALLOC_GROW does not copy anything to the new memory area. This subtly broke the call to strbuf_getline in read_next_command() [fast-import.c:1855], which goes strbuf_detach(&command_buf, NULL); # command_buf is now = STRBUF_INIT stdin_eof = strbuf_getline(&command_buf, stdin, '\n'); if (stdin_eof) return EOF; In strbuf_getwholeline, this did strbuf_grow(sb, 0); # loses nul-termination if (feof(fp)) return EOF; strbuf_reset(sb); # this would have nul-terminated! Valgrind found this because fast-import subsequently uses prefixcmp() on command_buf.buf, which after the EOF exit contains only uninitialized memory. Arguably strbuf_getwholeline is also broken, in that it touches the buffer before deciding whether to do any work. However, it seems more futureproof to not let the strbuf API lose the nul-termination by its own fault. So make sure that strbuf_grow() puts in a nul even if it has nowhere to copy it from. This makes strbuf_grow(sb, 0) a semantic no-op as far as readers of the buffer are concerned. Also remove the nul-termination added by strbuf_init, which is made redudant. Signed-off-by: Thomas Rast <trast@student.ethz.ch> Signed-off-by: Junio C Hamano <gitster@pobox.com>
* | | | | | | | | | Merge branch 'tr/maint-ident-to-git-memmove'Junio C Hamano2011-09-021-2/+2
|\ \ \ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * tr/maint-ident-to-git-memmove: Use memmove in ident_to_git
| * | | | | | | | | | Use memmove in ident_to_gitThomas Rast2011-08-291-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | convert_to_git sets src=dst->buf if any of the preceding conversions actually did any work. Thus in ident_to_git we have to use memmove instead of memcpy as far as src->dst copying is concerned. Signed-off-by: Thomas Rast <trast@student.ethz.ch> Signed-off-by: Junio C Hamano <gitster@pobox.com>