{"thread":{"id":"23987","subject":"What's cooking in git.git (Jun 2010, #01; Wed, 2)","startedAt":"2010-06-02T23:36:56Z","lastAt":"2010-06-07T05:04:16Z","messageCount":23,"participants":["Junio C Hamano","Tay Ray Chuan","Michael J Gruber","Clemens Buchacher","Thomas Rast","Jonathan Nieder","Eyvind Bernhardsen","Sverre Rabbelier"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"142846","messageId":"7v4ohlatwn.fsf@alter.siamese.dyndns.org","threadId":"23987","inReplyTo":null,"subject":"What's cooking in git.git (Jun 2010, #01; Wed, 2)","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-06-02T23:36:56Z","receivedAt":"2010-06-02T23:36:56Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Here are the topics that have been cooking.  Commits prefixed with '-' are\nonly in 'pu' while commits prefixed with '+' are in 'next'.  The ones\nmarked with '.' do not appear in any of the integration branches, but I am\nstill holding onto them.\n\nMany topics that have been cooking since 1.7.1 pre-release freeze period\nare now in master; maybe it is a good time to start freezing feature\nbranches for 1.7.2---I think I said I'll keep this cycle shorter, no?\n\n--------------------------------------------------\n[New Topics]\n\n* bs/userdiff-php (2010-05-23) 1 commit\n - diff: Support visibility modifiers in the PHP hunk header regexp\n\nWill merge to 'next'.\n\n* cc/maint-diff-CC-binary (2010-06-02) 2 commits\n - fixup\n - diff: fix \"git show -C -C\" output when renaming a binary file\n\nThe fix-up should probably be squashed in, as the original \"fix\" was\nbarking up a wrong tree.\n\n* jn/gitweb-plackup (2010-05-28) 3 commits\n - git-instaweb: Add support for running gitweb via 'plackup'\n - git-instaweb: Wait for server to start before running web browser\n - git-instaweb: Remove pidfile after stopping web server\n (this branch uses ps/gitweb-soc.)\n\nWill merge to 'next'.\n\n* mg/status-b (2010-05-25) 2 commits\n - Documentation+t5708: document and test status -s -b\n - Show branch information in short output of git status\n\nThere are a few style violations that snuck in, but otherwise looked\nsensible.\n\n* ps/gitweb-soc (2010-05-28) 4 commits\n - git-instaweb: Configure it to work with new gitweb structure\n - git-instaweb: Put httpd logs in a \"$httpd_only\" subdirectory\n - gitweb: Set default destination directory for installing gitweb in Makefile\n - gitweb: Move static files into seperate subdirectory\n (this branch is used by jn/gitweb-plackup.)\n\nWill merge to 'next'.\n\n* tc/commit-abbrev-fix (2010-05-27) 3 commits\n - commit::print_summary(): set rev_info.always_show_header to 1\n - t7502-commit: add summary output tests for empty and merge commits\n - t7502-commit: add tests for summary output\n\nWill merge to 'next'.  I am not quite happy about the \"impossible to\ntrigger\" die message, though.  It is a good defensive programming to catch\nbreakages caused by future changes that may invalidate the assumption this\npatch makes, but then the message should be worded as such to state that\nassumption, I think.\n\n* ab/maint-perl-use-instlibdir (2010-05-30) 1 commit\n - Makefile: remove redundant munging of @@INSTLIBDIR@@\n\nWill merge to 'next'.\n\n* by/diff-graph (2010-05-29) 6 commits\n - Make --color-words work well with --graph\n - graph.c: register a callback for graph output\n - Emit a whole line in one go\n - diff.c: Output the text graph padding before each diff line\n - Output the graph columns at the end of the commit message\n - Add a prefix output callback to diff output\n\nWill merge to 'next'.\n\n* cc/cherry-pick-series (2010-06-02) 8 commits\n - Documentation/revert: describe passing more than one commit\n - Documentation/cherry-pick: describe passing more than one commit\n - revert: add tests to check cherry-picking many commits\n - revert: allow cherry-picking more than one commit\n - revert: change help_msg() to take no argument\n - revert: refactor code into a do_pick_commit() function\n - revert: use run_command_v_opt() instead of execv_git_cmd()\n - revert: cleanup code for -x option\n\n* gs/usage-to-stdout (2010-05-17) 1 commit\n - print the usage string on stdout instead of stderr\n\nWill merge to 'next'.\n\n* gv/portable (2010-05-14) 18 commits\n - Makefile: Tru64 portability fix\n - Makefile: HP-UX 10.20 portability fixes\n - Makefile: HPUX11 portability fixes\n - Makefile: SunOS 5.6 portability fix\n - inline declaration does not work on AIX\n - Allow disabling \"inline\"\n - Some platforms lack socklen_t type\n - Make NO_{INET_NTOP,INET_PTON} configured independently\n - Makefile: some platforms do not have hstrerror anywhere\n - git-compat-util.h: some platforms with mmap() lack MAP_FAILED definition\n - test_cmp: do not use \"diff -u\" on platforms that lack one\n - fixup: do not unconditionally disable \"diff -u\"\n - tests: use \"test_cmp\", not \"diff\", when verifying the result\n - Do not use \"diff\" found on PATH while building and installing\n - enums: omit trailing comma for portability\n - Makefile: -lpthread may still be necessary when libc has only pthread stubs\n - Rewrite dynamic structure initializations to runtime assignment\n - Makefile: pass CPPFLAGS through to fllow customization\n\nWill merge to 'next'.\n\n* jh/diff-index-line-abbrev (2010-05-30) 1 commit\n - diff.c: Ensure \"index $from..$to\" line contains unambiguous SHA1s\n\nWill merge to 'next'.\n\n* jk/am-skip-hint (2010-05-30) 1 commit\n - git-am: suggest what to do with superfluous patches\n\nWill merge to 'next'.\n\n* jn/checkout-doc (2010-05-30) 1 commit\n - Documentation/checkout: clarify description\n\nWill merge to 'next'.\n\n* jn/fsck-ident (2010-05-26) 1 commit\n - fsck: fix bogus commit header check\n\nWill merge to 'next'.\n\n* jn/maint-doc-ignore (2010-03-05) 1 commit\n - gitignore.5: Clarify matching rules\n\nWill merge to 'next'.\n\n* jn/rebase-cmdline-fix (2010-05-31) 1 commit\n - rebase: improve error message when upstream argument is missing\n\nWill merge to 'next'.\n\n* ps/gitweb--browse-chrome (2010-05-30) 1 commit\n - git-web--browse: Add support for google chrome and chromium\n\nWill merge to 'next'.\n\n* bc/portable (2010-06-01) 5 commits\n - t/aggregate-results: accomodate systems with small max argument list length\n - t/t7006: ignore return status of shell's unset builtin\n - t/t5150: remove space from sed script\n - git-request-pull.sh: remove -e switch to shell interpreter which breaks ksh\n - t/t5800: skip if python version is older than 2.5\n\n* jn/show-num-walks (2010-06-01) 1 commit\n - DWIM 'git show -5' to 'git show --do-walk -5'\n\n* rr/am-help (2010-06-02) 3 commits\n - git am: Remove stray error message from sed\n - git am: Display some help text when patch is empty\n - git am: Set cmdline globally\n\nWill merge to 'next'.\n\n* jc/t9129-any-utf8 (2010-06-02) 1 commit\n - t9129: fix UTF-8 locale detection\n\n--------------------------------------------------\n[Stalled -- would discard unless there are some movements soon]\n\n* jc/rev-list-ancestry-path (2010-04-20) 1 commit\n - revision: --ancestry-path\n\nJust an illustration patch.  merge simplification logic used when\npathspecs are in effect interacts with this rather badly.\n\n* js/rebase-origin-x (2010-02-05) 1 commit\n - [RFC w/o test and incomplete] rebase: add -x option to record original commit name\n\nI retract my objection against the idea of -x; needs polishing before\nmoving forward.\n\n* js/grep-open (2010-05-01) 3 commits\n - grep: do not ignore return value from chdir()\n - grep -O: allow optional argument specifying the pager (or editor)\n - grep: Add the option '--open-files-in-pager'\n (this branch is used by jp/hold-string-list-sanity.)\n\nProbably needs to support --no-index mode as well.\n\n--------------------------------------------------\n[Cooking]\n\n* em/checkout-orphan (2010-05-21) 5 commits\n - bash completion: add --orphan to 'git checkout'\n - t3200: test -l with core.logAllRefUpdates options\n - checkout --orphan: respect -l option always\n - refs: split log_ref_write logic into log_ref_setup\n - Documentation: alter checkout --orphan description\n\nIn <4BFE2461.5080501@drmicha.warpmail.net>, Michael J Gruber raised a\nvalid request for a better explanation of superfluous files left behind\nand then are cleaned.  Other than that I think this is a sane thing to\ndo.\n\n* ec/diff-noprefix-config (2010-05-02) 1 commit\n - diff: add configuration option for disabling diff prefixes.\n\nWill merge to 'next'.\n\n* jk/diff-m-doc (2010-05-08) 1 commit\n - docs: clarify meaning of -M for git-log\n\nWill merge to 'next'.\n\n* mc/maint-zoneparse (2010-05-17) 1 commit\n - Add \"Z\" as an alias for the timezone \"UTC\"\n\nWill merge to 'next'.\n\n* mg/notes-dry-run (2010-05-14) 1 commit\n - notes: dry-run and verbose options for prune\n\nWill merge to 'next'.\n\n* mg/rev-parse-lrbranches-locals (2010-05-14) 1 commit\n - revlist: Introduce --lrbranches and --locals revision specifiers\n (this branch uses mg/rev-parse-option-sifter-deprecation.)\n\nHmmm...\n\n* mg/rev-parse-option-sifter-deprecation (2010-05-14) 3 commits\n - t6018: make sure all tested symbolic names are different revs\n - t6018: add tests for rev-list's --branches and --tags\n - rev-parse: deprecate use as an option sifter\n (this branch is used by mg/rev-parse-lrbranches-locals.)\n\nSome people might interpret \"Deprecate\" too strongly; the intent is that\nwe shouldn't keep piling parsing of new rev-list options to it and\ndiscourage the use of \"option sifter\" in new programs.\n\n* ab/cvsserver (2010-05-15) 6 commits\n - git-cvsserver: test for pserver authentication support\n - git-cvsserver: document making a password without htpasswd\n - git-cvsserver: Improved error handling for pserver\n - git-cvsserver: indent & clean up authdb code\n - git-cvsserver: use a password file cvsserver pserver\n - git-cvsserver: authentication support for pserver\n\nWill merge to 'next'.\n\n* eb/core-eol (2010-05-19) 4 commits\n - Add \"core.eol\" config variable\n - Rename the \"crlf\" attribute \"text\"\n - Add per-repository eol normalization\n - Add tests for per-repository eol normalization\n (this branch uses fg/autocrlf.)\n\nWill merge to 'next'.\n\n* jn/remote-set-branches (2010-05-19) 1 commit\n - Add git remote set-branches\n\nWill merge to 'next'.\n\n* js/maint-windows (2009-07-20) 2 commits\n  (merged to 'next' on 2010-05-21 at 16abe03)\n + Recent MinGW has a C99 implementation of snprintf functions\n + mingw: use _commit to implement fsync\n\nWill merge to 'next'.\n\n* rs/grep-binary (2010-05-22) 8 commits\n - grep: support NUL chars in search strings for -F\n - grep: use REG_STARTEND for all matching if available\n - grep: continue case insensitive fixed string search after NUL chars\n - grep: use memmem() for fixed string search\n - grep: --name-only over binary\n - grep: --count over binary\n - grep: grep: refactor handling of binary mode options\n - grep: add test script for binary file handling\n\nWill merge to 'next'.\n\n* ab/submodule-foreach-toplevel (2010-05-21) 1 commit\n - git-submodule foreach: Add $toplevel variable\n\nWill merge to 'next'.\n\n* cb/ls-files-cdup (2010-05-26) 1 commit\n - ls-files: allow relative pathspec\n\nDoesn't write_name() quote twice when prefix_offset is non-zero?\n\n* jk/maint-pull-dry-run-noop (2010-05-25) 1 commit\n - pull: do nothing on --dry-run\n\nWill merge to 'next'.\n\n* jk/maint-sha1-file-name-fix (2010-05-22) 1 commit\n - remove over-eager caching in sha1_file_name\n\nWill merge to 'next'.\n\n* jk/url-decode (2010-05-23) 2 commits\n - decode file:// and ssh:// URLs\n - make url-related functions reusable\n\nWill merge to 'next'.\n\n* bw/diff-metainfo-color (2010-05-04) 1 commit\n  (merged to 'next' on 2010-05-21 at 3aa552e)\n + diff: fix coloring of extended diff headers\n\n* ph/clone-message-reword (2010-05-09) 1 commit\n  (merged to 'next' on 2010-05-21 at 1785bd0)\n + clone: reword messages to match the end-user perception\n\n* rc/ls-remote-default (2010-05-12) 1 commit\n - ls-remote: print URL when no repo is specified\n\nWill merge to 'next'.\n\n* fg/autocrlf (2010-05-12) 1 commit\n  (merged to 'next' on 2010-05-21 at 5f43b66)\n + autocrlf: Make it work also for un-normalized repositories\n (this branch is used by eb/core-eol.)\n\n* tc/merge-m-log (2010-05-11) 8 commits\n  (merged to 'next' on 2010-05-21 at e889876)\n + merge: --log appends shortlog to message if specified\n + fmt-merge-msg: add function to append shortlog only\n + fmt-merge-msg: refactor merge title formatting\n + fmt-merge-msg: minor refactor of fmt_merge_msg()\n + merge: rename variable\n + merge: update comment\n + t7604-merge-custom-message: show that --log doesn't append to -m\n + t7604-merge-custom-message: shift expected output creation\n\n* jn/gitweb-fastcgi (2010-05-07) 2 commits\n  (merged to 'next' on 2010-05-21 at cb1724f)\n + gitweb: Add support for FastCGI, using CGI::Fast\n + gitweb: Put all per-connection code in run() subroutine\n\n* jn/make-header-dependency (2010-05-08) 2 commits\n  (merged to 'next' on 2010-05-21 at d4ed230)\n + Makefile: let header dependency checker override COMPUTE_HEADER_DEPENDENCIES\n + Makefile: fix header dependency checker to allow NO_CURL builds\n\n* js/try-to-free-stackable (2010-05-08) 2 commits\n  (merged to 'next' on 2010-05-21 at 4c1afcb)\n + Do not call release_pack_memory in malloc wrappers when GIT_TRACE is used\n + Have set_try_to_free_routine return the previous routine\n\n* jn/gitweb-syntax-highlight (2010-04-27) 2 commits\n - gitweb: Refactor syntax highlighting support\n - gitweb: Syntax highlighting support\n\nWill merge to 'next'.\n\n* jn/maint-amend-missing-name (2010-05-02) 1 commit\n  (merged to 'next' on 2010-05-09 at 9023332)\n + commit --amend: cope with missing display name\n\n* rs/diff-no-minimal (2010-05-02) 1 commit\n  (merged to 'next' on 2010-05-09 at 6c74aa0)\n + git diff too slow for a file\n\n* ab/test-cleanup (2010-05-07) 2 commits\n  (merged to 'next' on 2010-05-21 at a3cbd67)\n + Turn setup code in t2007-checkout-symlink.sh into a test\n + Move t6000lib.sh to lib-*\n\n* jn/notes-doc (2010-05-08) 8 commits\n  (merged to 'next' on 2010-05-21 at 1c28059)\n + Documentation/notes: nitpicks\n + Documentation/notes: clean up description of rewriting configuration\n + Documentation/notes: simplify treatment of default display refs\n + Documentation/log: add a CONFIGURATION section\n + Documentation/notes: simplify treatment of default notes ref\n + Documentation/notes: add configuration section\n + Documentation/notes: describe content of notes blobs\n + Documentation/notes: document format of notes trees\n\n* cb/assume-unchanged-fix (2010-05-01) 2 commits\n  (merged to 'next' on 2010-05-21 at bab2342)\n + Documentation: git-add does not update files marked \"assume unchanged\"\n + do not overwrite files marked \"assume unchanged\"\n\n* wp/pretty-enhancement (2010-05-08) 4 commits\n  (merged to 'next' on 2010-05-09 at eeaa4dc)\n + pretty: initialize new cmt_fmt_map to 0\n + pretty: add aliases for pretty formats\n + pretty: add infrastructure for commit format aliases\n + pretty: make it easier to add new formats\n\n* hg/id-munging (2010-04-06) 2 commits\n - convert: Keep foreign $Id$ on checkout.\n - convert: Safer handling of $Id$ contraction.\n\nWill merge to 'next'.\n\n* js/async-thread (2010-03-09) 7 commits\n  (merged to 'next' on 2010-05-21 at 9d31940)\n + Enable threaded async procedures whenever pthreads is available\n  (merged to 'next' on 2010-05-04 at 2644e74)\n + Dying in an async procedure should only exit the thread, not the process.\n + Reimplement async procedures using pthreads\n + Windows: more pthreads functions\n + Fix signature of fcntl() compatibility dummy\n + Make report() from usage.c public as vreportf() and use it.\n + Modernize t5530-upload-pack-error.\n\n(all except for the tip has been in 'next' since 2010-03-20).\n\n* ld/discovery-limit-to-fs (2010-04-04) 1 commit\n - write-index: check and warn when worktree crosses a filesystem boundary\n\nThere might have been some valid objections to this but I cannot recall.\nWill merge to 'next' unless I hear something within a few days.\n\n--------------------------------------------------\n[Discarded, perhaps can be rerolled]\n\n* jp/hold-string-list-sanity (2010-04-06) 9 commits\n . string_list: Fix argument order for string_list_append\n . Merge branch 'sr/remote-helper-export' into HEAD\n . Merge branch 'js/grep-open' into HEAD\n . Merge branch 'sb/fmt-merge-msg' into HEAD\n . string_list: Fix argument order for string_list_lookup\n . string_list: Fix argument order for string_list_insert_at_index\n . string_list: Fix argument order for string_list_insert\n . string_list: Fix argument order for for_each_string_list\n . string_list: Fix argument order for print_string_list\n (this branch uses js/grep-open.)\n\nBuilding this on top of slushy codebase is not a very promising endeavor.\nGood thing to do, but it came at a bad time.\n"},{"id":"142853","messageId":"AANLkTimuTIugURlYxwbk7wGW2IM11YTy4P91YDguLQUb@mail.gmail.com","threadId":"23987","inReplyTo":"7v4ohlatwn.fsf@alter.siamese.dyndns.org","subject":"Re: What's cooking in git.git (Jun 2010, #01; Wed, 2)","fromName":"Tay Ray Chuan","fromEmail":"rctay89@gmail.com","sentAt":"2010-06-03T03:13:45Z","receivedAt":"2010-06-03T03:13:45Z","isPatch":false,"sender":{"key":"rctay89@gmail.com","avatar":"https://avatars.githubusercontent.com/u/61553?v=4"},"body":"Hi,\n\nOn Thu, Jun 3, 2010 at 7:36 AM, Junio C Hamano <gitster@pobox.com> wrote:\n> [New Topics]\n> [snip]\n> * tc/commit-abbrev-fix (2010-05-27) 3 commits\n>  - commit::print_summary(): set rev_info.always_show_header to 1\n>  - t7502-commit: add summary output tests for empty and merge commits\n>  - t7502-commit: add tests for summary output\n>\n> Will merge to 'next'.  I am not quite happy about the \"impossible to\n> trigger\" die message, though.  It is a good defensive programming to catch\n> breakages caused by future changes that may invalidate the assumption this\n> patch makes, but then the message should be worded as such to state that\n> assumption, I think.\n\nI'll try to remember to re-send the third patch with your suggestion\nabout the message.\n\n> [Cooking]\n> [snip]\n> * tc/merge-m-log (2010-05-11) 8 commits\n>  (merged to 'next' on 2010-05-21 at e889876)\n>  + merge: --log appends shortlog to message if specified\n>  + fmt-merge-msg: add function to append shortlog only\n>  + fmt-merge-msg: refactor merge title formatting\n>  + fmt-merge-msg: minor refactor of fmt_merge_msg()\n>  + merge: rename variable\n>  + merge: update comment\n>  + t7604-merge-custom-message: show that --log doesn't append to -m\n>  + t7604-merge-custom-message: shift expected output creation\n\nFWIW, I've been using this feature for as long as it's been cooking -\nno issues thus far.\n\n-- \nCheers,\nRay Chuan\n"},{"id":"142864","messageId":"4C076A6C.601@drmicha.warpmail.net","threadId":"23987","inReplyTo":"7v4ohlatwn.fsf@alter.siamese.dyndns.org","subject":"Re: What's cooking in git.git (Jun 2010, #01; Wed, 2)","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2010-06-03T08:40:12Z","receivedAt":"2010-06-03T08:40:12Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Junio C Hamano venit, vidit, dixit 03.06.2010 01:36:\n> Here are the topics that have been cooking.  Commits prefixed with '-' are\n> only in 'pu' while commits prefixed with '+' are in 'next'.  The ones\n> marked with '.' do not appear in any of the integration branches, but I am\n> still holding onto them.\n> \n> Many topics that have been cooking since 1.7.1 pre-release freeze period\n> are now in master; maybe it is a good time to start freezing feature\n> branches for 1.7.2---I think I said I'll keep this cycle shorter, no?\n> \n> --------------------------------------------------\n> [New Topics]\n> * mg/status-b (2010-05-25) 2 commits\n>  - Documentation+t5708: document and test status -s -b\n>  - Show branch information in short output of git status\n> \n> There are a few style violations that snuck in, but otherwise looked\n> sensible.\n\nI tried to follow surrounding style. Or do you mean the \"if(\" and local\nvariable initialisations in David'd patch? Do you want any of us to\nrecheck and resubmit?\n\nI'm running with David's -b all the time, btw, it dramatically reduced\nmy need for long-status. Works great.\n\n> --------------------------------------------------\n> [Stalled -- would discard unless there are some movements soon]\n> \n> * jc/rev-list-ancestry-path (2010-04-20) 1 commit\n>  - revision: --ancestry-path\n> \n> Just an illustration patch.  merge simplification logic used when\n> pathspecs are in effect interacts with this rather badly.\n\nI think it's still useful. Do all rev-walker flags need to interact\nsanely with each other? We could just discourage --ancestry-path with\nmerge-simplification (and later try to reconcile them).\n\n> --------------------------------------------------\n> [Cooking]\n> \n> * em/checkout-orphan (2010-05-21) 5 commits\n>  - bash completion: add --orphan to 'git checkout'\n>  - t3200: test -l with core.logAllRefUpdates options\n>  - checkout --orphan: respect -l option always\n>  - refs: split log_ref_write logic into log_ref_setup\n>  - Documentation: alter checkout --orphan description\n> \n> In <4BFE2461.5080501@drmicha.warpmail.net>, Michael J Gruber raised a\n> valid request for a better explanation of superfluous files left behind\n> and then are cleaned.  Other than that I think this is a sane thing to\n> do.\n\nGot no response but had the impression that retracting myself from the\ndiscussion may improve the willingness of the submitter :)\n\n> * mg/rev-parse-lrbranches-locals (2010-05-14) 1 commit\n>  - revlist: Introduce --lrbranches and --locals revision specifiers\n>  (this branch uses mg/rev-parse-option-sifter-deprecation.)\n> \n> Hmmm...\n\nNow I know what to do ;)\n\nAnother approach would be to have something like \"ref aliases\". I often\nuse origin/next..origin/pu and origin/next@{1}..origin/next for example.\nMaybe allowing something like\n\n[refalias]\n\tpuextra\t= origin/next..origin/pu\n\tpunew\t= origin/next@{1}..origin/next\n\tlocals\t= HEAD --branches --tags\n\tlrbranches = --branches --remotes\n\nwould make more sense and allows for personal choices. Hmmm? ;)\n\n> \n> * mg/rev-parse-option-sifter-deprecation (2010-05-14) 3 commits\n>  - t6018: make sure all tested symbolic names are different revs\n>  - t6018: add tests for rev-list's --branches and --tags\n>  - rev-parse: deprecate use as an option sifter\n>  (this branch is used by mg/rev-parse-lrbranches-locals.)\n> \n> Some people might interpret \"Deprecate\" too strongly; the intent is that\n> we shouldn't keep piling parsing of new rev-list options to it and\n> discourage the use of \"option sifter\" in new programs.\n\nSo, s/deprecated/discouraged/? Is there an alternative we should suggest\nthere for scripts needing to sift their options?\n\nCheers,\nMichael\n"},{"id":"142879","messageId":"20100603133631.GA31565@localhost","threadId":"23987","inReplyTo":"7v4ohlatwn.fsf@alter.siamese.dyndns.org","subject":"[PATCH 1/2] separate quoting and relative path generation","fromName":"Clemens Buchacher","fromEmail":"drizzd@aon.at","sentAt":"2010-06-03T13:36:31Z","receivedAt":"2010-06-03T13:36:31Z","isPatch":true,"sender":{"key":"drizzd@gmx.net","avatar":"https://avatars.githubusercontent.com/u/59082?v=4"},"body":"This is in preparation of relative path support for ls-files, which\nquotes a path only if the line terminator is not the NUL character.\n\nSigned-off-by: Clemens Buchacher <drizzd@aon.at>\n---\n\nOn Wed, Jun 02, 2010 at 04:36:56PM -0700, Junio C Hamano wrote:\n\n> * cb/ls-files-cdup (2010-05-26) 1 commit\n>  - ls-files: allow relative pathspec\n> \n> Doesn't write_name() quote twice when prefix_offset is non-zero?\n\nYes. Fixed in the following two patches.\n\n quote.c |   69 +++++++++++++++++++++++++++++++++++++++++---------------------\n quote.h |    8 ++++++-\n 2 files changed, 52 insertions(+), 25 deletions(-)\n\ndiff --git a/quote.c b/quote.c\nindex fc93435..2ae2c1f 100644\n--- a/quote.c\n+++ b/quote.c\n@@ -295,42 +295,63 @@ void write_name_quotedpfx(const char *pfx, size_t pfxlen,\n \tfputc(terminator, fp);\n }\n \n-/* quote path as relative to the given prefix */\n-char *quote_path_relative(const char *in, int len,\n-\t\t\t  struct strbuf *out, const char *prefix)\n+void write_name_quoted_relative(const char *name, size_t len,\n+\t\t\t\tconst char *prefix, size_t prefix_len,\n+\t\t\t\tFILE *fp, int terminator)\n {\n-\tint needquote;\n+\tstruct strbuf sb = STRBUF_INIT;\n \n+\tchar *path = path_relative(name, len, &sb, prefix, prefix_len);\n+\twrite_name_quoted(path, fp, terminator);\n+\n+\tstrbuf_release(&sb);\n+}\n+\n+/* give path as relative to prefix */\n+char *path_relative(const char *in, int len,\n+\t\t    struct strbuf *out, const char *prefix, int prefix_len)\n+{\n \tif (len < 0)\n \t\tlen = strlen(in);\n+\tif (prefix && prefix_len < 0)\n+\t\tprefix_len = strlen(prefix);\n \n-\t/* \"../\" prefix itself does not need quoting, but \"in\" might. */\n-\tneedquote = next_quote_pos(in, len) < len;\n \tstrbuf_setlen(out, 0);\n \tstrbuf_grow(out, len);\n \n-\tif (needquote)\n-\t\tstrbuf_addch(out, '\"');\n-\tif (prefix) {\n-\t\tint off = 0;\n-\t\twhile (prefix[off] && off < len && prefix[off] == in[off])\n-\t\t\tif (prefix[off] == '/') {\n-\t\t\t\tprefix += off + 1;\n-\t\t\t\tin += off + 1;\n-\t\t\t\tlen -= off + 1;\n-\t\t\t\toff = 0;\n-\t\t\t} else\n-\t\t\t\toff++;\n-\n-\t\tfor (; *prefix; prefix++)\n-\t\t\tif (*prefix == '/')\n+\tif (prefix_len > 0) {\n+\t\tint off = 0, i = 0;\n+\t\twhile (i < prefix_len && i < len && prefix[i] == in[i]) {\n+\t\t\tif (prefix[i] == '/')\n+\t\t\t\toff = i + 1;\n+\t\t\ti++;\n+\t\t}\n+\t\tin += off;\n+\t\tlen -= off;\n+\n+\t\twhile (i < prefix_len) {\n+\t\t\tif (prefix[i] == '/')\n \t\t\t\tstrbuf_addstr(out, \"../\");\n+\t\t\ti++;\n+\t\t}\n \t}\n+\tstrbuf_add(out, in, len);\n+\n+\treturn out->buf;\n+}\n+\n+/* quote path as relative to the given prefix */\n+char *quote_path_relative(const char *in, int len,\n+\t\t\t  struct strbuf *out, const char *prefix)\n+{\n+\tchar *rel;\n+\tsize_t rel_len;\n \n-\tquote_c_style_counted (in, len, out, NULL, 1);\n+\tpath_relative(in, len, out, prefix, -1);\n+\trel = strbuf_detach(out, &rel_len);\n+\tquote_c_style_counted(rel, rel_len, out, NULL, 0);\n+\tfree(rel);\n \n-\tif (needquote)\n-\t\tstrbuf_addch(out, '\"');\n \tif (!out->len)\n \t\tstrbuf_addstr(out, \"./\");\n \ndiff --git a/quote.h b/quote.h\nindex f83eb23..e9e0221 100644\n--- a/quote.h\n+++ b/quote.h\n@@ -54,9 +54,15 @@ extern void quote_two_c_style(struct strbuf *, const char *, const char *, int);\n extern void write_name_quoted(const char *name, FILE *, int terminator);\n extern void write_name_quotedpfx(const char *pfx, size_t pfxlen,\n                                  const char *name, FILE *, int terminator);\n+extern void write_name_quoted_relative(const char *name, size_t len,\n+\t\tconst char *prefix, size_t prefix_len,\n+\t\tFILE *fp, int terminator);\n \n+/* give path as relative to prefix */\n+extern char *path_relative(const char *in, int len,\n+\t\tstruct strbuf *out, const char *prefix, int prefix_len);\n /* quote path as relative to the given prefix */\n-char *quote_path_relative(const char *in, int len,\n+extern char *quote_path_relative(const char *in, int len,\n \t\t\t  struct strbuf *out, const char *prefix);\n \n /* quoting as a string literal for other languages */\n-- \n1.7.1.2.g2a651\n"},{"id":"142880","messageId":"20100603133918.GB31565@localhost","threadId":"23987","inReplyTo":"20100603133631.GA31565@localhost","subject":"[PATCH 2/2] ls-files: allow relative pathspec","fromName":"Clemens Buchacher","fromEmail":"drizzd@aon.at","sentAt":"2010-06-03T13:39:18Z","receivedAt":"2010-06-03T13:39:18Z","isPatch":true,"sender":{"key":"drizzd@gmx.net","avatar":"https://avatars.githubusercontent.com/u/59082?v=4"},"body":"git ls-files used to error out if given paths which point outside the current\nworking directory, such as '../'. We now allow such paths and the output is\nanalogous to git grep -l.\n\nSigned-off-by: Clemens Buchacher <drizzd@aon.at>\n---\n\nThere are two changes with respect to the previous version of this\npatch.\n\n- write_name() now uses the new write_name_quoted_relative()\n- prefix_offset is renamed to prefix_len, which is much more\n  intuitive\n\nClemens\n\n builtin/ls-files.c |   75 ++++++++++++++++++++++++++++-----------------------\n t/t7010-setup.sh   |   12 +++-----\n 2 files changed, 45 insertions(+), 42 deletions(-)\n\ndiff --git a/builtin/ls-files.c b/builtin/ls-files.c\nindex c0fbcdc..0804047 100644\n--- a/builtin/ls-files.c\n+++ b/builtin/ls-files.c\n@@ -26,8 +26,9 @@ static int show_killed;\n static int show_valid_bit;\n static int line_terminator = '\\n';\n \n+static const char *prefix;\n+static int max_prefix_len;\n static int prefix_len;\n-static int prefix_offset;\n static const char **pathspec;\n static int error_unmatch;\n static char *ps_matched;\n@@ -43,10 +44,15 @@ static const char *tag_modified = \"\";\n static const char *tag_skip_worktree = \"\";\n static const char *tag_resolve_undo = \"\";\n \n+static void write_name(const char* name, size_t len)\n+{\n+\twrite_name_quoted_relative(name, len, prefix, prefix_len, stdout,\n+\t\t\tline_terminator);\n+}\n+\n static void show_dir_entry(const char *tag, struct dir_entry *ent)\n {\n-\tint len = prefix_len;\n-\tint offset = prefix_offset;\n+\tint len = max_prefix_len;\n \n \tif (len >= ent->len)\n \t\tdie(\"git ls-files: internal error - directory entry not superset of prefix\");\n@@ -55,7 +61,7 @@ static void show_dir_entry(const char *tag, struct dir_entry *ent)\n \t\treturn;\n \n \tfputs(tag, stdout);\n-\twrite_name_quoted(ent->name + offset, stdout, line_terminator);\n+\twrite_name(ent->name, ent->len);\n }\n \n static void show_other_files(struct dir_struct *dir)\n@@ -121,8 +127,7 @@ static void show_killed_files(struct dir_struct *dir)\n \n static void show_ce_entry(const char *tag, struct cache_entry *ce)\n {\n-\tint len = prefix_len;\n-\tint offset = prefix_offset;\n+\tint len = max_prefix_len;\n \n \tif (len >= ce_namelen(ce))\n \t\tdie(\"git ls-files: internal error - cache entry not superset of prefix\");\n@@ -156,20 +161,19 @@ static void show_ce_entry(const char *tag, struct cache_entry *ce)\n \t\t       find_unique_abbrev(ce->sha1,abbrev),\n \t\t       ce_stage(ce));\n \t}\n-\twrite_name_quoted(ce->name + offset, stdout, line_terminator);\n+\twrite_name(ce->name, ce_namelen(ce));\n }\n \n static int show_one_ru(struct string_list_item *item, void *cbdata)\n {\n-\tint offset = prefix_offset;\n \tconst char *path = item->string;\n \tstruct resolve_undo_info *ui = item->util;\n \tint i, len;\n \n \tlen = strlen(path);\n-\tif (len < prefix_len)\n+\tif (len < max_prefix_len)\n \t\treturn 0; /* outside of the prefix */\n-\tif (!match_pathspec(pathspec, path, len, prefix_len, ps_matched))\n+\tif (!match_pathspec(pathspec, path, len, max_prefix_len, ps_matched))\n \t\treturn 0; /* uninterested */\n \tfor (i = 0; i < 3; i++) {\n \t\tif (!ui->mode[i])\n@@ -177,19 +181,19 @@ static int show_one_ru(struct string_list_item *item, void *cbdata)\n \t\tprintf(\"%s%06o %s %d\\t\", tag_resolve_undo, ui->mode[i],\n \t\t       find_unique_abbrev(ui->sha1[i], abbrev),\n \t\t       i + 1);\n-\t\twrite_name_quoted(path + offset, stdout, line_terminator);\n+\t\twrite_name(path, len);\n \t}\n \treturn 0;\n }\n \n-static void show_ru_info(const char *prefix)\n+static void show_ru_info(void)\n {\n \tif (!the_index.resolve_undo)\n \t\treturn;\n \tfor_each_string_list(show_one_ru, the_index.resolve_undo, NULL);\n }\n \n-static void show_files(struct dir_struct *dir, const char *prefix)\n+static void show_files(struct dir_struct *dir)\n {\n \tint i;\n \n@@ -243,7 +247,7 @@ static void show_files(struct dir_struct *dir, const char *prefix)\n  */\n static void prune_cache(const char *prefix)\n {\n-\tint pos = cache_name_pos(prefix, prefix_len);\n+\tint pos = cache_name_pos(prefix, max_prefix_len);\n \tunsigned int first, last;\n \n \tif (pos < 0)\n@@ -256,7 +260,7 @@ static void prune_cache(const char *prefix)\n \twhile (last > first) {\n \t\tint next = (last + first) >> 1;\n \t\tstruct cache_entry *ce = active_cache[next];\n-\t\tif (!strncmp(ce->name, prefix, prefix_len)) {\n+\t\tif (!strncmp(ce->name, prefix, max_prefix_len)) {\n \t\t\tfirst = next+1;\n \t\t\tcontinue;\n \t\t}\n@@ -265,11 +269,16 @@ static void prune_cache(const char *prefix)\n \tactive_nr = last;\n }\n \n-static const char *verify_pathspec(const char *prefix)\n+static const char *pathspec_prefix(const char *prefix)\n {\n \tconst char **p, *n, *prev;\n \tunsigned long max;\n \n+\tif (!pathspec) {\n+\t\tmax_prefix_len = prefix ? strlen(prefix) : 0;\n+\t\treturn prefix;\n+\t}\n+\n \tprev = NULL;\n \tmax = PATH_MAX;\n \tfor (p = pathspec; (n = *p) != NULL; p++) {\n@@ -291,10 +300,7 @@ static const char *verify_pathspec(const char *prefix)\n \t\t}\n \t}\n \n-\tif (prefix_offset > max || memcmp(prev, prefix, prefix_offset))\n-\t\tdie(\"git ls-files: cannot generate relative filenames containing '..'\");\n-\n-\tprefix_len = max;\n+\tmax_prefix_len = max;\n \treturn max ? xmemdupz(prev, max) : NULL;\n }\n \n@@ -374,7 +380,7 @@ void overlay_tree_on_cache(const char *tree_name, const char *prefix)\n \t}\n }\n \n-int report_path_error(const char *ps_matched, const char **pathspec, int prefix_offset)\n+int report_path_error(const char *ps_matched, const char **pathspec, int prefix_len)\n {\n \t/*\n \t * Make sure all pathspec matched; otherwise it is an error.\n@@ -404,7 +410,7 @@ int report_path_error(const char *ps_matched, const char **pathspec, int prefix_\n \t\t\tcontinue;\n \n \t\terror(\"pathspec '%s' did not match any file(s) known to git.\",\n-\t\t      pathspec[num] + prefix_offset);\n+\t\t      pathspec[num] + prefix_len);\n \t\terrors++;\n \t}\n \treturn errors;\n@@ -456,9 +462,10 @@ static int option_parse_exclude_standard(const struct option *opt,\n \treturn 0;\n }\n \n-int cmd_ls_files(int argc, const char **argv, const char *prefix)\n+int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix)\n {\n \tint require_work_tree = 0, show_tag = 0;\n+\tconst char *max_prefix;\n \tstruct dir_struct dir;\n \tstruct option builtin_ls_files_options[] = {\n \t\t{ OPTION_CALLBACK, 'z', NULL, NULL, NULL,\n@@ -504,7 +511,7 @@ int cmd_ls_files(int argc, const char **argv, const char *prefix)\n \t\t{ OPTION_CALLBACK, 0, \"exclude-standard\", &dir, NULL,\n \t\t\t\"add the standard git exclusions\",\n \t\t\tPARSE_OPT_NOARG, option_parse_exclude_standard },\n-\t\t{ OPTION_SET_INT, 0, \"full-name\", &prefix_offset, NULL,\n+\t\t{ OPTION_SET_INT, 0, \"full-name\", &prefix_len, NULL,\n \t\t\t\"make the output relative to the project top directory\",\n \t\t\tPARSE_OPT_NOARG | PARSE_OPT_NONEG, NULL },\n \t\tOPT_BOOLEAN(0, \"error-unmatch\", &error_unmatch,\n@@ -516,8 +523,9 @@ int cmd_ls_files(int argc, const char **argv, const char *prefix)\n \t};\n \n \tmemset(&dir, 0, sizeof(dir));\n+\tprefix = cmd_prefix;\n \tif (prefix)\n-\t\tprefix_offset = strlen(prefix);\n+\t\tprefix_len = strlen(prefix);\n \tgit_config(git_default_config, NULL);\n \n \tif (read_cache() < 0)\n@@ -555,9 +563,8 @@ int cmd_ls_files(int argc, const char **argv, const char *prefix)\n \tif (pathspec)\n \t\tstrip_trailing_slash_from_submodules();\n \n-\t/* Verify that the pathspec matches the prefix */\n-\tif (pathspec)\n-\t\tprefix = verify_pathspec(prefix);\n+\t/* Find common prefix for all pathspec's */\n+\tmax_prefix = pathspec_prefix(prefix);\n \n \t/* Treat unmatching pathspec elements as errors */\n \tif (pathspec && error_unmatch) {\n@@ -575,8 +582,8 @@ int cmd_ls_files(int argc, const char **argv, const char *prefix)\n \t      show_killed | show_modified | show_resolve_undo))\n \t\tshow_cached = 1;\n \n-\tif (prefix)\n-\t\tprune_cache(prefix);\n+\tif (max_prefix)\n+\t\tprune_cache(max_prefix);\n \tif (with_tree) {\n \t\t/*\n \t\t * Basic sanity check; show-stages and show-unmerged\n@@ -584,15 +591,15 @@ int cmd_ls_files(int argc, const char **argv, const char *prefix)\n \t\t */\n \t\tif (show_stage || show_unmerged)\n \t\t\tdie(\"ls-files --with-tree is incompatible with -s or -u\");\n-\t\toverlay_tree_on_cache(with_tree, prefix);\n+\t\toverlay_tree_on_cache(with_tree, max_prefix);\n \t}\n-\tshow_files(&dir, prefix);\n+\tshow_files(&dir);\n \tif (show_resolve_undo)\n-\t\tshow_ru_info(prefix);\n+\t\tshow_ru_info();\n \n \tif (ps_matched) {\n \t\tint bad;\n-\t\tbad = report_path_error(ps_matched, pathspec, prefix_offset);\n+\t\tbad = report_path_error(ps_matched, pathspec, prefix_len);\n \t\tif (bad)\n \t\t\tfprintf(stderr, \"Did you forget to 'git add'?\\n\");\n \ndiff --git a/t/t7010-setup.sh b/t/t7010-setup.sh\nindex d8a7c79..0335a9a 100755\n--- a/t/t7010-setup.sh\n+++ b/t/t7010-setup.sh\n@@ -103,14 +103,10 @@ test_expect_success 'git ls-files (relative #3)' '\n \tgit add a &&\n \t(\n \t\tcd a/b &&\n-\t\tif git ls-files \"../e/f\"\n-\t\tthen\n-\t\t\techo Gaah, should have failed\n-\t\t\texit 1\n-\t\telse\n-\t\t\t: happy\n-\t\tfi\n-\t)\n+\t\tgit ls-files \"../e/f\"\n+\t)  >current &&\n+\techo ../e/f >expect &&\n+\ttest_cmp expect current\n \n '\n \n-- \n1.7.1.2.g2a651\n"},{"id":"142890","messageId":"201006031636.25418.trast@student.ethz.ch","threadId":"23987","inReplyTo":"7v4ohlatwn.fsf@alter.siamese.dyndns.org","subject":"Re: What's cooking in git.git (Jun 2010, #01; Wed, 2)","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2010-06-03T14:36:25Z","receivedAt":"2010-06-03T14:36:25Z","isPatch":false,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Junio C Hamano wrote:\n> * ld/discovery-limit-to-fs (2010-04-04) 1 commit\n>  - write-index: check and warn when worktree crosses a filesystem boundary\n> \n> There might have been some valid objections to this but I cannot recall.\n> Will merge to 'next' unless I hear something within a few days.\n\nHmm, this actually got me wondering a bit if you meant my comment on\nthe original series, relating to my use of tmpfs for t/ [1].  Peff\npointed me to an existing and better solution and you rightfully\nignored this.\n\nThe patch above is the one at [2] and did not get any replies, so I\nthink you do not even have to wait :-)\n\n(FWIW, I think it's a good idea to warn but I didn't look at the patch\nmuch.)\n\n\n[1] http://thread.gmane.org/gmane.comp.version-control.git/142436/focus=143617\n[2] http://thread.gmane.org/gmane.comp.version-control.git/142436/focus=143959\n\n-- \nThomas Rast\ntrast@{inf,student}.ethz.ch\n"},{"id":"142915","messageId":"20100603182513.GA25093@progeny.tock","threadId":"23987","inReplyTo":"4C076A6C.601@drmicha.warpmail.net","subject":"mg/rev-parse-option-sifter-deprecation","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-06-03T18:25:13Z","receivedAt":"2010-06-03T18:25:13Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Hi,\n\nMichael J Gruber wrote:\n> Junio C Hamano venit, vidit, dixit 03.06.2010 01:36:\n\n>> Some people might interpret \"Deprecate\" too strongly; the intent is that\n>> we shouldn't keep piling parsing of new rev-list options to it and\n>> discourage the use of \"option sifter\" in new programs.\n>\n> So, s/deprecated/discouraged/? Is there an alternative we should suggest\n> there for scripts needing to sift their options?\n\nAh, I was wondering about this, too.\n\nMost git tools use parseopt now, whether they are written in sh or C.\nWhen I first read this deprecation, I thought, \"Wait --- so rev-parse\n--parseopt is going away?\"  So it might make sense to mention\nrev-parse --parseopt separately in the description section.\n\nAs for --revs-only and --no-revs, the problem aiui is that we have no\nin-tree users for them except git filter-branch.  Worse still, they\nshare no code with setup_revisions().  Would it be sensible to change\nthis?\n\n - teach setup_revisions() to use an option sifter instead of parsing\n   options in one pass (probably a bad idea), or\n\n - give setup_revisions a second identity as an option sifter, or\n\n - teach filter-branch to do its own sifting of filespec arguments\n   from revision arguments, and let rev-parse --revs-only rot\n\nUnfortunately, any one of these changes would take time; so to be\nrealistic, regardless of what else happens, the deprecation notice\nseems like the right thing to do.\n\n| You can use linkgit:git-rev-list[1] directly or\n| +linkgit:git-for-each-ref[1] for scripting.\n\nI do not understand the reference to for-each-ref here.\n\nThanks,\nJonathan\n"},{"id":"142921","messageId":"7E7FBDDC-2504-4145-8822-E28ED410B799@gmail.com","threadId":"23987","inReplyTo":"7v4ohlatwn.fsf@alter.siamese.dyndns.org","subject":"Re: What's cooking in git.git (Jun 2010, #01; Wed, 2)","fromName":"Eyvind Bernhardsen","fromEmail":"eyvind.bernhardsen@gmail.com","sentAt":"2010-06-03T19:53:47Z","receivedAt":"2010-06-03T19:53:47Z","isPatch":false,"sender":{"key":"eyvind.bernhardsen@gmail.com","avatar":"https://avatars.githubusercontent.com/u/106762?v=4"},"body":"Hi,\n\nOn 3. juni 2010, at 01.36, Junio C Hamano wrote:\n\n> * eb/core-eol (2010-05-19) 4 commits\n> - Add \"core.eol\" config variable\n> - Rename the \"crlf\" attribute \"text\"\n> - Add per-repository eol normalization\n> - Add tests for per-repository eol normalization\n> (this branch uses fg/autocrlf.)\n> \n> Will merge to 'next'.\n\nI have a fixup for the \"core.eol\" commit that modifies \"core.autocrlf\"'s behaviour and fixes the documentation, as discussed on the list.  Unfortunately it's on a machine that's not accessible to me right now, but I'll send it tomorrow.\n-- \nEyvind\n"},{"id":"142932","messageId":"7vocfr7oe6.fsf@alter.siamese.dyndns.org","threadId":"23987","inReplyTo":"20100603133631.GA31565@localhost","subject":"Re: [PATCH 1/2] separate quoting and relative path generation","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-06-03T22:16:33Z","receivedAt":"2010-06-03T22:16:33Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Clemens Buchacher <drizzd@aon.at> writes:\n\n> +/* give path as relative to prefix */\n> +char *path_relative(const char *in, int len,\n> +\t\t    struct strbuf *out, const char *prefix, int prefix_len)\n> +{\n>  \tif (len < 0)\n>  \t\tlen = strlen(in);\n> +\tif (prefix && prefix_len < 0)\n> +\t\tprefix_len = strlen(prefix);\n>  \n>  \tstrbuf_setlen(out, 0);\n>  \tstrbuf_grow(out, len);\n>  \n> +\tif (prefix_len > 0) {\n> +\t\tint off = 0, i = 0;\n> +\t\twhile (i < prefix_len && i < len && prefix[i] == in[i]) {\n> +\t\t\tif (prefix[i] == '/')\n> +\t\t\t\toff = i + 1;\n> +\t\t\ti++;\n> +\t\t}\n> +\t\tin += off;\n> +\t\tlen -= off;\n> +\n> +\t\twhile (i < prefix_len) {\n> +\t\t\tif (prefix[i] == '/')\n>  \t\t\t\tstrbuf_addstr(out, \"../\");\n> +\t\t\ti++;\n> +\t\t}\n>  \t}\n> +\tstrbuf_add(out, in, len);\n> +\n> +\treturn out->buf;\n> +}\n\nHmm...  I wonder if we really want to always make a copy of the string in\nthe majority of the case where there is no need to add ../ and the path\ndoes not have any funny characters that needs quoting.  In such a case,\nshouldn't write_name() be just moving the pointers into the original\nstring to skip the $(cwd) part and writing the remainder of the string\nout, without any extra allocation nor copy?  IIUC, that is what the\noriginal did using write_name_quoted().\n"},{"id":"142946","messageId":"20100604074442.GA5117@localhost","threadId":"23987","inReplyTo":"7vocfr7oe6.fsf@alter.siamese.dyndns.org","subject":"[PATCH] optimize path_relative()","fromName":"Clemens Buchacher","fromEmail":"drizzd@aon.at","sentAt":"2010-06-04T07:44:43Z","receivedAt":"2010-06-04T07:44:43Z","isPatch":true,"sender":{"key":"drizzd@gmx.net","avatar":"https://avatars.githubusercontent.com/u/59082?v=4"},"body":"Avoid copying to strbuf in case a subset of the original string can\nbe returned.\n\nSince the strbuf is no longer guaranteed to be updated, this\nfunction is different from quote_path_relative(). To avoid\nconfusion, do not export it.\n\nSigned-off-by: Clemens Buchacher <drizzd@aon.at>\n---\nOn Thu, Jun 03, 2010 at 03:16:33PM -0700, Junio C Hamano wrote:\n> Clemens Buchacher <drizzd@aon.at> writes:\n>\n> > +\tstrbuf_add(out, in, len);\n> > +\n> > +\treturn out->buf;\n> > +}\n> \n> Hmm...  I wonder if we really want to always make a copy of the string in\n> the majority of the case where there is no need to add ../ and the path\n> does not have any funny characters that needs quoting.\n\nRight. Implemented below. I noticed a few more redundancies along\nthe way, so the following could be squashed into 1/2 \"separate\nquoting and relative path generation\" or applied on top of the\nexisting two patches.\n\nPlease let me know if you'd rather have a resend.\n\nClemens\n\n quote.c |   72 ++++++++++++++++++++++++++++++++++++--------------------------\n quote.h |    3 --\n 2 files changed, 42 insertions(+), 33 deletions(-)\n\ndiff --git a/quote.c b/quote.c\nindex 2ae2c1f..481541a 100644\n--- a/quote.c\n+++ b/quote.c\n@@ -295,62 +295,74 @@ void write_name_quotedpfx(const char *pfx, size_t pfxlen,\n \tfputc(terminator, fp);\n }\n \n+static const char *path_relative(const char *in, int len,\n+\t\t\t\t struct strbuf *sb, const char *prefix,\n+\t\t\t\t int prefix_len);\n+\n void write_name_quoted_relative(const char *name, size_t len,\n \t\t\t\tconst char *prefix, size_t prefix_len,\n \t\t\t\tFILE *fp, int terminator)\n {\n \tstruct strbuf sb = STRBUF_INIT;\n \n-\tchar *path = path_relative(name, len, &sb, prefix, prefix_len);\n-\twrite_name_quoted(path, fp, terminator);\n+\tname = path_relative(name, len, &sb, prefix, prefix_len);\n+\twrite_name_quoted(name, fp, terminator);\n \n \tstrbuf_release(&sb);\n }\n \n-/* give path as relative to prefix */\n-char *path_relative(const char *in, int len,\n-\t\t    struct strbuf *out, const char *prefix, int prefix_len)\n+/*\n+ * Give path as relative to prefix.\n+ *\n+ * The strbuf may or may not be used, so do not assume it contains the\n+ * returned path.\n+ */\n+static const char *path_relative(const char *in, int len,\n+\t\t\t\t struct strbuf *sb, const char *prefix,\n+\t\t\t\t int prefix_len)\n {\n+\tint off, i;\n+\n \tif (len < 0)\n \t\tlen = strlen(in);\n \tif (prefix && prefix_len < 0)\n \t\tprefix_len = strlen(prefix);\n \n-\tstrbuf_setlen(out, 0);\n-\tstrbuf_grow(out, len);\n+\toff = 0;\n+\ti = 0;\n+\twhile (i < prefix_len && i < len && prefix[i] == in[i]) {\n+\t\tif (prefix[i] == '/')\n+\t\t\toff = i + 1;\n+\t\ti++;\n+\t}\n+\tin += off;\n+\tlen -= off;\n \n-\tif (prefix_len > 0) {\n-\t\tint off = 0, i = 0;\n-\t\twhile (i < prefix_len && i < len && prefix[i] == in[i]) {\n-\t\t\tif (prefix[i] == '/')\n-\t\t\t\toff = i + 1;\n-\t\t\ti++;\n-\t\t}\n-\t\tin += off;\n-\t\tlen -= off;\n+\tif (i == prefix_len)\n+\t\treturn in;\n \n-\t\twhile (i < prefix_len) {\n-\t\t\tif (prefix[i] == '/')\n-\t\t\t\tstrbuf_addstr(out, \"../\");\n-\t\t\ti++;\n-\t\t}\n+\tstrbuf_reset(sb);\n+\tstrbuf_grow(sb, len);\n+\n+\twhile (i < prefix_len) {\n+\t\tif (prefix[i] == '/')\n+\t\t\tstrbuf_addstr(sb, \"../\");\n+\t\ti++;\n \t}\n-\tstrbuf_add(out, in, len);\n+\tstrbuf_add(sb, in, len);\n \n-\treturn out->buf;\n+\treturn sb->buf;\n }\n \n /* quote path as relative to the given prefix */\n char *quote_path_relative(const char *in, int len,\n \t\t\t  struct strbuf *out, const char *prefix)\n {\n-\tchar *rel;\n-\tsize_t rel_len;\n-\n-\tpath_relative(in, len, out, prefix, -1);\n-\trel = strbuf_detach(out, &rel_len);\n-\tquote_c_style_counted(rel, rel_len, out, NULL, 0);\n-\tfree(rel);\n+\tstruct strbuf sb = STRBUF_INIT;\n+\tconst char *rel = path_relative(in, len, &sb, prefix, -1);\n+\tstrbuf_reset(out);\n+\tquote_c_style_counted(rel, strlen(rel), out, NULL, 0);\n+\tstrbuf_release(&sb);\n \n \tif (!out->len)\n \t\tstrbuf_addstr(out, \"./\");\ndiff --git a/quote.h b/quote.h\nindex e9e0221..38003bf 100644\n--- a/quote.h\n+++ b/quote.h\n@@ -58,9 +58,6 @@ extern void write_name_quoted_relative(const char *name, size_t len,\n \t\tconst char *prefix, size_t prefix_len,\n \t\tFILE *fp, int terminator);\n \n-/* give path as relative to prefix */\n-extern char *path_relative(const char *in, int len,\n-\t\tstruct strbuf *out, const char *prefix, int prefix_len);\n /* quote path as relative to the given prefix */\n extern char *quote_path_relative(const char *in, int len,\n \t\t\t  struct strbuf *out, const char *prefix);\n-- \n1.7.1.2.ga1f6e\n"},{"id":"142947","messageId":"20100604075034.GB5117@localhost","threadId":"23987","inReplyTo":"20100604074442.GA5117@localhost","subject":"Re: [PATCH] optimize path_relative()","fromName":"Clemens Buchacher","fromEmail":"drizzd@aon.at","sentAt":"2010-06-04T07:50:34Z","receivedAt":"2010-06-04T07:50:34Z","isPatch":true,"sender":{"key":"drizzd@gmx.net","avatar":"https://avatars.githubusercontent.com/u/59082?v=4"},"body":"On Fri, Jun 04, 2010 at 09:44:43AM +0200, Clemens Buchacher wrote:\n\n> +static const char *path_relative(const char *in, int len,\n> +\t\t\t\t struct strbuf *sb, const char *prefix,\n> +\t\t\t\t int prefix_len)\n>  {\n> +\tint off, i;\n> +\n>  \tif (len < 0)\n>  \t\tlen = strlen(in);\n>  \tif (prefix && prefix_len < 0)\n>  \t\tprefix_len = strlen(prefix);\n>  \n> -\tstrbuf_setlen(out, 0);\n> -\tstrbuf_grow(out, len);\n> +\toff = 0;\n> +\ti = 0;\n> +\twhile (i < prefix_len && i < len && prefix[i] == in[i]) {\n> +\t\tif (prefix[i] == '/')\n> +\t\t\toff = i + 1;\n> +\t\ti++;\n> +\t}\n> +\tin += off;\n> +\tlen -= off;\n>  \n> -\tif (prefix_len > 0) {\n> -\t\tint off = 0, i = 0;\n> -\t\twhile (i < prefix_len && i < len && prefix[i] == in[i]) {\n> -\t\t\tif (prefix[i] == '/')\n> -\t\t\t\toff = i + 1;\n> -\t\t\ti++;\n> -\t\t}\n> -\t\tin += off;\n> -\t\tlen -= off;\n> +\tif (i == prefix_len)\n> +\t\treturn in;\n>  \n> -\t\twhile (i < prefix_len) {\n> -\t\t\tif (prefix[i] == '/')\n> -\t\t\t\tstrbuf_addstr(out, \"../\");\n> -\t\t\ti++;\n> -\t\t}\n> +\tstrbuf_reset(sb);\n> +\tstrbuf_grow(sb, len);\n> +\n> +\twhile (i < prefix_len) {\n> +\t\tif (prefix[i] == '/')\n> +\t\t\tstrbuf_addstr(sb, \"../\");\n> +\t\ti++;\n>  \t}\n\nBy the way, I noticed that we rely on the fact that a non-empty\nprefix ends with '/'. Is that ok?\n\n> -\tstrbuf_add(out, in, len);\n> +\tstrbuf_add(sb, in, len);\n>  \n> -\treturn out->buf;\n> +\treturn sb->buf;\n>  }\n"},{"id":"142949","messageId":"1275639660-5344-1-git-send-email-rctay89@gmail.com","threadId":"23987","inReplyTo":"AANLkTimuTIugURlYxwbk7wGW2IM11YTy4P91YDguLQUb@mail.gmail.com","subject":"[PATCH v3 3/3] commit::print_summary(): set rev_info.always_show_header to 1","fromName":"Tay Ray Chuan","fromEmail":"rctay89@gmail.com","sentAt":"2010-06-04T08:21:00Z","receivedAt":"2010-06-04T08:21:00Z","isPatch":true,"sender":{"key":"rctay89@gmail.com","avatar":"https://avatars.githubusercontent.com/u/61553?v=4"},"body":"This attempts to fix a regression in git-commit, where non-abbreviated\nSHA-1s were printed in the summary.\n\nOne possible fix would be to set ctx.abbrev to DEFAULT_ABBREV in the\n`if` block.\n\nHowever, we remove this codeblock altogether, and set\nrev.always_show_header. This way, we use back the same show_log()\nmechanism (instead of format_commit_message()).\n\nQuoting log-tree.c:560:\n\n\tshown = log_tree_diff(opt, commit, &log);\n\tif (!shown && opt->loginfo && opt->always_show_header) {\n\t\tlog.parent = NULL;\n\t\tshow_log(opt);\n\t\tshown = 1;\n\t}\n\nThis is the only area that always_show_header is checked, so the\nsetting of this flag should only affect this area.\n\nAlso, we now die() if log_tree_commit() returns false. Based on the\nexisting underlying codepaths (log_tree_commit(), log_tree_diff(),\nlog_tree_diff_flush(), to name a few), this should not occur; changes to\nthese codepaths may warrant a revision of our handling of this\nsituation. Tests #2 and #3 in t7502 should aid in detecting such\nbreakages.\n\nSigned-off-by: Tay Ray Chuan <rctay89@gmail.com>\n---\n\nThis is a reworked version of the third patch of the\n'tc/commit-abbrev-fix' series; there are no changes to the first and\nsecond patches.\n\nChanges from v2:\n - shift around 2nd and 3rd paras.\n - mention the die() and our assumption that it won't be triggered, as\n   suggested by Junio.\n\n builtin/commit.c  |   13 ++++---------\n t/t7502-commit.sh |    4 ++--\n 2 files changed, 6 insertions(+), 11 deletions(-)\n\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex a4e4966..2884d0c 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -1148,7 +1148,7 @@ static void print_summary(const char *prefix, const unsigned char *sha1)\n \trev.verbose_header = 1;\n \trev.show_root_diff = 1;\n \tget_commit_format(format.buf, &rev);\n-\trev.always_show_header = 0;\n+\trev.always_show_header = 1;\n \trev.diffopt.detect_rename = 1;\n \trev.diffopt.rename_limit = 100;\n \trev.diffopt.break_opt = 0;\n@@ -1162,14 +1162,9 @@ static void print_summary(const char *prefix, const unsigned char *sha1)\n \t\t\t\thead,\n \t\tinitial_commit ? \" (root-commit)\" : \"\");\n\n-\tif (!log_tree_commit(&rev, commit)) {\n-\t\tstruct pretty_print_context ctx = {0};\n-\t\tstruct strbuf buf = STRBUF_INIT;\n-\t\tctx.date_mode = DATE_NORMAL;\n-\t\tformat_commit_message(commit, format.buf + 7, &buf, &ctx);\n-\t\tprintf(\"%s\\n\", buf.buf);\n-\t\tstrbuf_release(&buf);\n-\t}\n+\tif (!log_tree_commit(&rev, commit))\n+\t\tdie(\"unable to print summary\");\n+\n \tstrbuf_release(&format);\n }\n\ndiff --git a/t/t7502-commit.sh b/t/t7502-commit.sh\nindex b10541d..08c0247 100755\n--- a/t/t7502-commit.sh\n+++ b/t/t7502-commit.sh\n@@ -36,12 +36,12 @@ test_expect_success 'output summary format' '\n \tcheck_summary_oneline \"\" \"a change\"\n '\n\n-test_expect_failure 'output summary format for commit with an empty diff' '\n+test_expect_success 'output summary format for commit with an empty diff' '\n\n \tcheck_summary_oneline \"\" \"empty\" \"--allow-empty\"\n '\n\n-test_expect_failure 'output summary format for merges' '\n+test_expect_success 'output summary format for merges' '\n\n \tgit checkout -b recursive-base &&\n \ttest_commit base file1 &&\n--\n1.7.1.189.g07419\n"},{"id":"142950","messageId":"AANLkTilv7gR6ewVpvwS0PPaNAj4FC446PYZAX2RKLT8O@mail.gmail.com","threadId":"23987","inReplyTo":"1275639660-5344-1-git-send-email-rctay89@gmail.com","subject":"Re: [PATCH v3 3/3] commit::print_summary(): set rev_info.always_show_header to 1","fromName":"Tay Ray Chuan","fromEmail":"rctay89@gmail.com","sentAt":"2010-06-04T08:34:28Z","receivedAt":"2010-06-04T08:34:28Z","isPatch":true,"sender":{"key":"rctay89@gmail.com","avatar":"https://avatars.githubusercontent.com/u/61553?v=4"},"body":"Hi Will,\n\nsorry, I forgot to Cc you for this new version.\n\n-- \nCheers,\nRay Chuan\n\nOn Fri, Jun 4, 2010 at 4:21 PM, Tay Ray Chuan <rctay89@gmail.com> wrote:\n> This attempts to fix a regression in git-commit, where non-abbreviated\n> SHA-1s were printed in the summary.\n>\n> One possible fix would be to set ctx.abbrev to DEFAULT_ABBREV in the\n> `if` block.\n>\n> However, we remove this codeblock altogether, and set\n> rev.always_show_header. This way, we use back the same show_log()\n> mechanism (instead of format_commit_message()).\n>\n> Quoting log-tree.c:560:\n>\n>        shown = log_tree_diff(opt, commit, &log);\n>        if (!shown && opt->loginfo && opt->always_show_header) {\n>                log.parent = NULL;\n>                show_log(opt);\n>                shown = 1;\n>        }\n>\n> This is the only area that always_show_header is checked, so the\n> setting of this flag should only affect this area.\n>\n> Also, we now die() if log_tree_commit() returns false. Based on the\n> existing underlying codepaths (log_tree_commit(), log_tree_diff(),\n> log_tree_diff_flush(), to name a few), this should not occur; changes to\n> these codepaths may warrant a revision of our handling of this\n> situation. Tests #2 and #3 in t7502 should aid in detecting such\n> breakages.\n>\n> Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>\n> ---\n>\n> This is a reworked version of the third patch of the\n> 'tc/commit-abbrev-fix' series; there are no changes to the first and\n> second patches.\n>\n> Changes from v2:\n>  - shift around 2nd and 3rd paras.\n>  - mention the die() and our assumption that it won't be triggered, as\n>   suggested by Junio.\n>\n>  builtin/commit.c  |   13 ++++---------\n>  t/t7502-commit.sh |    4 ++--\n>  2 files changed, 6 insertions(+), 11 deletions(-)\n>\n> diff --git a/builtin/commit.c b/builtin/commit.c\n> index a4e4966..2884d0c 100644\n> --- a/builtin/commit.c\n> +++ b/builtin/commit.c\n> @@ -1148,7 +1148,7 @@ static void print_summary(const char *prefix, const unsigned char *sha1)\n>        rev.verbose_header = 1;\n>        rev.show_root_diff = 1;\n>        get_commit_format(format.buf, &rev);\n> -       rev.always_show_header = 0;\n> +       rev.always_show_header = 1;\n>        rev.diffopt.detect_rename = 1;\n>        rev.diffopt.rename_limit = 100;\n>        rev.diffopt.break_opt = 0;\n> @@ -1162,14 +1162,9 @@ static void print_summary(const char *prefix, const unsigned char *sha1)\n>                                head,\n>                initial_commit ? \" (root-commit)\" : \"\");\n>\n> -       if (!log_tree_commit(&rev, commit)) {\n> -               struct pretty_print_context ctx = {0};\n> -               struct strbuf buf = STRBUF_INIT;\n> -               ctx.date_mode = DATE_NORMAL;\n> -               format_commit_message(commit, format.buf + 7, &buf, &ctx);\n> -               printf(\"%s\\n\", buf.buf);\n> -               strbuf_release(&buf);\n> -       }\n> +       if (!log_tree_commit(&rev, commit))\n> +               die(\"unable to print summary\");\n> +\n>        strbuf_release(&format);\n>  }\n>\n> diff --git a/t/t7502-commit.sh b/t/t7502-commit.sh\n> index b10541d..08c0247 100755\n> --- a/t/t7502-commit.sh\n> +++ b/t/t7502-commit.sh\n> @@ -36,12 +36,12 @@ test_expect_success 'output summary format' '\n>        check_summary_oneline \"\" \"a change\"\n>  '\n>\n> -test_expect_failure 'output summary format for commit with an empty diff' '\n> +test_expect_success 'output summary format for commit with an empty diff' '\n>\n>        check_summary_oneline \"\" \"empty\" \"--allow-empty\"\n>  '\n>\n> -test_expect_failure 'output summary format for merges' '\n> +test_expect_success 'output summary format for merges' '\n>\n>        git checkout -b recursive-base &&\n>        test_commit base file1 &&\n> --\n> 1.7.1.189.g07419\n>\n>\n"},{"id":"143003","messageId":"20100604211811.GA7471@progeny.tock","threadId":"23987","inReplyTo":"7v4ohlatwn.fsf@alter.siamese.dyndns.org","subject":"Re: What's cooking in git.git (Jun 2010, #01; Wed, 2)","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-06-04T21:18:11Z","receivedAt":"2010-06-04T21:18:11Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Junio C Hamano wrote:\n\n> * gv/portable (2010-05-14) 18 commits\n[...]\n>  - Do not use \"diff\" found on PATH while building and installing\n\nThat patch (d1b1a919) breaks merge-one-file when run outside the test\nsuite as far as I can tell.\n\nMaybe it could be made portable with ‘git diff --no-index’?\n\ndiff --git a/git-merge-one-file.sh b/git-merge-one-file.sh\nindex 3145009..d067894 100755\n--- a/git-merge-one-file.sh\n+++ b/git-merge-one-file.sh\n@@ -107,7 +107,7 @@ case \"${1:-.}${2:-.}${3:-.}\" in\n \t\t# remove lines that are unique to ours.\n \t\torig=`git-unpack-file $2`\n \t\tsz0=`wc -c <\"$orig\"`\n-\t\t$DIFF -u -La/$orig -Lb/$orig $orig $src2 | git apply --no-add\n+\t\tdiff -u -La/$orig -Lb/$orig $orig $src2 | git apply --no-add\n \t\tsz1=`wc -c <\"$orig\"`\n \n \t\t# If we do not have enough common material, it is not\n-- \n"},{"id":"143022","messageId":"7vljau0yi5.fsf@alter.siamese.dyndns.org","threadId":"23987","inReplyTo":"1275639660-5344-1-git-send-email-rctay89@gmail.com","subject":"Re: [PATCH v3 3/3] commit::print_summary(): set rev_info.always_show_header to 1","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-06-05T06:44:34Z","receivedAt":"2010-06-05T06:44:34Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Tay Ray Chuan <rctay89@gmail.com> writes:\n\n>  - mention the die() and our assumption that it won't be triggered, as\n>    suggested by Junio.\n\nWhat I meant was to state that in the die() message, not in the commit\nlog, so that a bug reporter (or preferably people hacking on git that\nintroduces a regression to trigger this die()) can quickly diagnose what\nassumption this new code relies on was violated.\n"},{"id":"143023","messageId":"20100605073728.GA19159@localhost","threadId":"23987","inReplyTo":"20100604074442.GA5117@localhost","subject":"[PATCH v2] optimize path_relative()","fromName":"Clemens Buchacher","fromEmail":"drizzd@aon.at","sentAt":"2010-06-05T07:37:28Z","receivedAt":"2010-06-05T07:37:28Z","isPatch":true,"sender":{"key":"drizzd@gmx.net","avatar":"https://avatars.githubusercontent.com/u/59082?v=4"},"body":"Avoid copying to strbuf in case a subset of the original string can\nbe returned.\n\nSince the strbuf is no longer guaranteed to be updated, this\nfunction is different from quote_path_relative(). To avoid\nconfusion, do not export it.\n\nSigned-off-by: Clemens Buchacher <drizzd@aon.at>\n---\n\nOn Fri, Jun 04, 2010 at 09:44:43AM +0200, Clemens Buchacher wrote:\n\n>  \tif (prefix && prefix_len < 0)\n>  \t\tprefix_len = strlen(prefix);\n[...]\n> +\tif (i == prefix_len)\n> +\t\treturn in;\n\nThis should have been i >= prefix_len, in case prefix = NULL and\nprefix_len = -1.  (Can only happen with git clean at the moment.)\n\n quote.c |   72 ++++++++++++++++++++++++++++++++++++--------------------------\n quote.h |    3 --\n 2 files changed, 42 insertions(+), 33 deletions(-)\n\ndiff --git a/quote.c b/quote.c\nindex 2ae2c1f..63d3b01 100644\n--- a/quote.c\n+++ b/quote.c\n@@ -295,62 +295,74 @@ void write_name_quotedpfx(const char *pfx, size_t pfxlen,\n \tfputc(terminator, fp);\n }\n \n+static const char *path_relative(const char *in, int len,\n+\t\t\t\t struct strbuf *sb, const char *prefix,\n+\t\t\t\t int prefix_len);\n+\n void write_name_quoted_relative(const char *name, size_t len,\n \t\t\t\tconst char *prefix, size_t prefix_len,\n \t\t\t\tFILE *fp, int terminator)\n {\n \tstruct strbuf sb = STRBUF_INIT;\n \n-\tchar *path = path_relative(name, len, &sb, prefix, prefix_len);\n-\twrite_name_quoted(path, fp, terminator);\n+\tname = path_relative(name, len, &sb, prefix, prefix_len);\n+\twrite_name_quoted(name, fp, terminator);\n \n \tstrbuf_release(&sb);\n }\n \n-/* give path as relative to prefix */\n-char *path_relative(const char *in, int len,\n-\t\t    struct strbuf *out, const char *prefix, int prefix_len)\n+/*\n+ * Give path as relative to prefix.\n+ *\n+ * The strbuf may or may not be used, so do not assume it contains the\n+ * returned path.\n+ */\n+static const char *path_relative(const char *in, int len,\n+\t\t\t\t struct strbuf *sb, const char *prefix,\n+\t\t\t\t int prefix_len)\n {\n+\tint off, i;\n+\n \tif (len < 0)\n \t\tlen = strlen(in);\n \tif (prefix && prefix_len < 0)\n \t\tprefix_len = strlen(prefix);\n \n-\tstrbuf_setlen(out, 0);\n-\tstrbuf_grow(out, len);\n+\toff = 0;\n+\ti = 0;\n+\twhile (i < prefix_len && i < len && prefix[i] == in[i]) {\n+\t\tif (prefix[i] == '/')\n+\t\t\toff = i + 1;\n+\t\ti++;\n+\t}\n+\tin += off;\n+\tlen -= off;\n \n-\tif (prefix_len > 0) {\n-\t\tint off = 0, i = 0;\n-\t\twhile (i < prefix_len && i < len && prefix[i] == in[i]) {\n-\t\t\tif (prefix[i] == '/')\n-\t\t\t\toff = i + 1;\n-\t\t\ti++;\n-\t\t}\n-\t\tin += off;\n-\t\tlen -= off;\n+\tif (i >= prefix_len)\n+\t\treturn in;\n \n-\t\twhile (i < prefix_len) {\n-\t\t\tif (prefix[i] == '/')\n-\t\t\t\tstrbuf_addstr(out, \"../\");\n-\t\t\ti++;\n-\t\t}\n+\tstrbuf_reset(sb);\n+\tstrbuf_grow(sb, len);\n+\n+\twhile (i < prefix_len) {\n+\t\tif (prefix[i] == '/')\n+\t\t\tstrbuf_addstr(sb, \"../\");\n+\t\ti++;\n \t}\n-\tstrbuf_add(out, in, len);\n+\tstrbuf_add(sb, in, len);\n \n-\treturn out->buf;\n+\treturn sb->buf;\n }\n \n /* quote path as relative to the given prefix */\n char *quote_path_relative(const char *in, int len,\n \t\t\t  struct strbuf *out, const char *prefix)\n {\n-\tchar *rel;\n-\tsize_t rel_len;\n-\n-\tpath_relative(in, len, out, prefix, -1);\n-\trel = strbuf_detach(out, &rel_len);\n-\tquote_c_style_counted(rel, rel_len, out, NULL, 0);\n-\tfree(rel);\n+\tstruct strbuf sb = STRBUF_INIT;\n+\tconst char *rel = path_relative(in, len, &sb, prefix, -1);\n+\tstrbuf_reset(out);\n+\tquote_c_style_counted(rel, strlen(rel), out, NULL, 0);\n+\tstrbuf_release(&sb);\n \n \tif (!out->len)\n \t\tstrbuf_addstr(out, \"./\");\ndiff --git a/quote.h b/quote.h\nindex e9e0221..38003bf 100644\n--- a/quote.h\n+++ b/quote.h\n@@ -58,9 +58,6 @@ extern void write_name_quoted_relative(const char *name, size_t len,\n \t\tconst char *prefix, size_t prefix_len,\n \t\tFILE *fp, int terminator);\n \n-/* give path as relative to prefix */\n-extern char *path_relative(const char *in, int len,\n-\t\tstruct strbuf *out, const char *prefix, int prefix_len);\n /* quote path as relative to the given prefix */\n extern char *quote_path_relative(const char *in, int len,\n \t\t\t  struct strbuf *out, const char *prefix);\n-- \n1.7.1.2.ga1f6e\n"},{"id":"143024","messageId":"20100605080420.GA1151@localhost","threadId":"23987","inReplyTo":"20100604075034.GB5117@localhost","subject":"[PATCH] setup: document prefix","fromName":"Clemens Buchacher","fromEmail":"drizzd@aon.at","sentAt":"2010-06-05T08:04:20Z","receivedAt":"2010-06-05T08:04:20Z","isPatch":true,"sender":{"key":"drizzd@gmx.net","avatar":"https://avatars.githubusercontent.com/u/59082?v=4"},"body":"Signed-off-by: Clemens Buchacher <drizzd@aon.at>\n---\n\nOn Fri, Jun 04, 2010 at 09:50:34AM +0200, Clemens Buchacher wrote:\n>\n> By the way, I noticed that we rely on the fact that a non-empty\n> prefix ends with '/'. Is that ok?\n\nI checked and the prefix does always end in a slash currently, but\nthis guarantee is well hidden in the code. I would feel more at\nease to continue relying on this with the comment below.\n\nRegards,\nClemens\n\n setup.c |    6 ++++++\n 1 files changed, 6 insertions(+), 0 deletions(-)\n\ndiff --git a/setup.c b/setup.c\nindex 5716d90..0e4cfe6 100644\n--- a/setup.c\n+++ b/setup.c\n@@ -519,6 +519,12 @@ int check_repository_format(void)\n \treturn check_repository_format_gently(NULL);\n }\n \n+/*\n+ * Returns the \"prefix\", a path to the current working directory\n+ * relative to the work tree root, or NULL, if the current working\n+ * directory is not a strict subdirectory of the work tree root. The\n+ * prefix always ends with a '/' character.\n+ */\n const char *setup_git_directory(void)\n {\n \tconst char *retval = setup_git_directory_gently(NULL);\n-- \n1.7.1.2.ga1f6e\n"},{"id":"143045","messageId":"7vaar9z73c.fsf@alter.siamese.dyndns.org","threadId":"23987","inReplyTo":"20100605073728.GA19159@localhost","subject":"Re: [PATCH v2] optimize path_relative()","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-06-05T18:07:19Z","receivedAt":"2010-06-05T18:07:19Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Clemens Buchacher <drizzd@aon.at> writes:\n\n> Avoid copying to strbuf in case a subset of the original string can\n> be returned.\n>\n> Since the strbuf is no longer guaranteed to be updated, this\n> function is different from quote_path_relative(). To avoid\n> confusion, do not export it.\n>\n> Signed-off-by: Clemens Buchacher <drizzd@aon.at>\n\nThe version of path_relative() after this patch looks much easier to\nfollow.\n\nI noticed that there is a similar function write_name_quotedpfx() defined\nin the same file, and wondered if we can do something similar to avoid the\nwhole allocation business.  But that would only be a microoptimize useful\nfor write_name_quoted_relative() and not for quote_path_relative() that\nhas a lot more callers, so it would probably not be worth it.\n\nThanks.\n"},{"id":"143046","messageId":"7v39x1z72z.fsf@alter.siamese.dyndns.org","threadId":"23987","inReplyTo":"20100604211811.GA7471@progeny.tock","subject":"Re: What's cooking in git.git (Jun 2010, #01; Wed, 2)","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-06-05T18:07:32Z","receivedAt":"2010-06-05T18:07:32Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jonathan Nieder <jrnieder@gmail.com> writes:\n\n> Junio C Hamano wrote:\n>\n>> * gv/portable (2010-05-14) 18 commits\n> [...]\n>>  - Do not use \"diff\" found on PATH while building and installing\n>\n> That patch (d1b1a919) breaks merge-one-file when run outside the test\n> suite as far as I can tell.\n\nThanks for catching.  I wonder if something like this would be better in\nthat it wouldn't break people who do not use custom \"DIFF\" while it would\nhelp people who do at the same time...\n\n Makefile              |    2 ++\n git-merge-one-file.sh |    2 +-\n 2 files changed, 3 insertions(+), 1 deletions(-)\n\ndiff --git a/Makefile b/Makefile\nindex bcb84be..0367e8a 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -1494,6 +1494,7 @@ SHELL_PATH_SQ = $(subst ','\\'',$(SHELL_PATH))\n PERL_PATH_SQ = $(subst ','\\'',$(PERL_PATH))\n PYTHON_PATH_SQ = $(subst ','\\'',$(PYTHON_PATH))\n TCLTK_PATH_SQ = $(subst ','\\'',$(TCLTK_PATH))\n+DIFF_SQ = $(subst ','\\'',$(DIFF))\n \n LIBS = $(GITLIBS) $(EXTLIBS)\n \n@@ -1582,6 +1583,7 @@ define cmd_munge_script\n $(RM) $@ $@+ && \\\n sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \\\n     -e 's|@SHELL_PATH@|$(SHELL_PATH_SQ)|' \\\n+    -e 's|@@DIFF@@|$(DIFF_SQ)|' \\\n     -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \\\n     -e 's/@@NO_CURL@@/$(NO_CURL)/g' \\\n     -e $(BROKEN_PATH_FIX) \\\ndiff --git a/git-merge-one-file.sh b/git-merge-one-file.sh\nindex 3145009..b86402a 100755\n--- a/git-merge-one-file.sh\n+++ b/git-merge-one-file.sh\n@@ -107,7 +107,7 @@ case \"${1:-.}${2:-.}${3:-.}\" in\n \t\t# remove lines that are unique to ours.\n \t\torig=`git-unpack-file $2`\n \t\tsz0=`wc -c <\"$orig\"`\n-\t\t$DIFF -u -La/$orig -Lb/$orig $orig $src2 | git apply --no-add\n+\t\t@@DIFF@@ -u -La/$orig -Lb/$orig $orig $src2 | git apply --no-add\n \t\tsz1=`wc -c <\"$orig\"`\n \n \t\t# If we do not have enough common material, it is not\n"},{"id":"143052","messageId":"20100605193247.GA5573@progeny.tock","threadId":"23987","inReplyTo":"7v39x1z72z.fsf@alter.siamese.dyndns.org","subject":"Re: What's cooking in git.git (Jun 2010, #01; Wed, 2)","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-06-05T19:32:47Z","receivedAt":"2010-06-05T19:32:47Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Jun 05, 2010 at 11:07:32AM -0700, Junio C Hamano wrote:\n\n> @@ -1582,6 +1583,7 @@ define cmd_munge_script\n>  $(RM) $@ $@+ && \\\n>  sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \\\n>      -e 's|@SHELL_PATH@|$(SHELL_PATH_SQ)|' \\\n> +    -e 's|@@DIFF@@|$(DIFF_SQ)|' \\\n>      -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \\\n>      -e 's/@@NO_CURL@@/$(NO_CURL)/g' \\\n>      -e $(BROKEN_PATH_FIX) \\\n> diff --git a/git-merge-one-file.sh b/git-merge-one-file.sh\n> index 3145009..b86402a 100755\n> --- a/git-merge-one-file.sh\n> +++ b/git-merge-one-file.sh\n> @@ -107,7 +107,7 @@ case \"${1:-.}${2:-.}${3:-.}\" in\n>  \t\t# remove lines that are unique to ours.\n>  \t\torig=`git-unpack-file $2`\n>  \t\tsz0=`wc -c <\"$orig\"`\n> -\t\t$DIFF -u -La/$orig -Lb/$orig $orig $src2 | git apply --no-add\n> +\t\t@@DIFF@@ -u -La/$orig -Lb/$orig $orig $src2 | git apply --no-add\n>  \t\tsz1=`wc -c <\"$orig\"`\n>  \n>  \t\t# If we do not have enough common material, it is not\n\nLooks good to me.  Thanks.\n"},{"id":"143068","messageId":"AANLkTimKwCDlW_uaCusZcmV2IttqORlUwSqkVnD3no6q@mail.gmail.com","threadId":"23987","inReplyTo":"7v39x1z72z.fsf@alter.siamese.dyndns.org","subject":"Re: What's cooking in git.git (Jun 2010, #01; Wed, 2)","fromName":"Sverre Rabbelier","fromEmail":"srabbelier@gmail.com","sentAt":"2010-06-05T23:57:24Z","receivedAt":"2010-06-05T23:57:24Z","isPatch":false,"sender":{"key":"srabbelier@gmail.com","avatar":"https://avatars.githubusercontent.com/u/3098?v=4"},"body":"Heya,\n\nOn Sat, Jun 5, 2010 at 20:07, Junio C Hamano <gitster@pobox.com> wrote:\n>> That patch (d1b1a919) breaks merge-one-file when run outside the test\n>> suite as far as I can tell.\n>\n> Thanks for catching.  I wonder if something like this would be better in\n> that it wouldn't break people who do not use custom \"DIFF\" while it would\n> help people who do at the same time...\n>\n>  Makefile              |    2 ++\n>  git-merge-one-file.sh |    2 +-\n\nNo addition to the test suite to catch this in the future?\n\n\n-- \nCheers,\n\nSverre Rabbelier\n"},{"id":"143071","messageId":"7vaar8yfmh.fsf@alter.siamese.dyndns.org","threadId":"23987","inReplyTo":"AANLkTimKwCDlW_uaCusZcmV2IttqORlUwSqkVnD3no6q@mail.gmail.com","subject":"Re: What's cooking in git.git (Jun 2010, #01; Wed, 2)","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-06-06T04:00:38Z","receivedAt":"2010-06-06T04:00:38Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Sverre Rabbelier <srabbelier@gmail.com> writes:\n\n> No addition to the test suite to catch this in the future?\n\nIf we had a test like this:\n\n    test_expect_success 'run resolve' '\n\t... set up something to merge ...\n        (\n        \tunset DIFF;\n                git merge -s resolve ...\n\t)\n    '\n\nit would have caught this particular breakage, but\n\n (1) nobody could have anticipated before the problematic patch that $DIFF\n     would be an exported variable that could cause trouble, so nobody\n     could have written it before the $DIFF patch;\n\n (2) with the knowledge necessary to write the above test, the $DIFF patch\n     wouldn't have made the misconversion, so it is unreasonable to say\n     that the $DIFF patch should have come with the above test; and\n\n (3) having the above test in the test suite may catch exactly the same\n     mistake in git-merge-one-file.sh, but that is not a guarantee that\n     nobody will break another scripted Porcelain that is not triggered in\n     the \"resolve\" codepath.\n\nOther than doing \"! git grep -e '$DIFF' 'git-\\*.sh'\" at the toplevel of\nthe source tree, I don't think it is possible to catch future bugs of this\nsort.\n"},{"id":"143132","messageId":"1275887056-4788-1-git-send-email-rctay89@gmail.com","threadId":"23987","inReplyTo":"1275639660-5344-1-git-send-email-rctay89@gmail.com","subject":"[PATCH v4] commit::print_summary(): set rev_info.always_show_header to 1","fromName":"Tay Ray Chuan","fromEmail":"rctay89@gmail.com","sentAt":"2010-06-07T05:04:16Z","receivedAt":"2010-06-07T05:04:16Z","isPatch":true,"sender":{"key":"rctay89@gmail.com","avatar":"https://avatars.githubusercontent.com/u/61553?v=4"},"body":"This attempts to fix a regression in git-commit, where non-abbreviated\nSHA-1s were printed in the summary.\n\nOne possible fix would be to set ctx.abbrev to DEFAULT_ABBREV in the\n`if` block.\n\nHowever, we remove this codeblock altogether, and set\nrev.always_show_header. This way, we use back the same show_log()\nmechanism (instead of format_commit_message()).\n\nQuoting log-tree.c:560:\n\n\tshown = log_tree_diff(opt, commit, &log);\n\tif (!shown && opt->loginfo && opt->always_show_header) {\n\t\tlog.parent = NULL;\n\t\tshow_log(opt);\n\t\tshown = 1;\n\t}\n\nThis is the only area that always_show_header is checked, so the\nsetting of this flag should only affect this area.\n\nAlso, we now die() if log_tree_commit() returns false; add a comment in\nthe area, which may be helpful to future git hackers (eg. diagnosisng\ntrigger of the die()).\n\nSigned-off-by: Tay Ray Chuan <rctay89@gmail.com>\n---\n\nThis is a reworked version of the third patch of the\n'tc/commit-abbrev-fix' series; there are no changes to the first and\nsecond patches.\n\nChanges from v3:\n - shift note on the die() and our assumption from the commit message into the\n   code (as a comment), as suggested by Junio.\n\n builtin/commit.c  |   22 +++++++++++++---------\n t/t7502-commit.sh |    4 ++--\n 2 files changed, 15 insertions(+), 11 deletions(-)\n\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex a4e4966..b0c266c 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -1148,7 +1148,7 @@ static void print_summary(const char *prefix, const unsigned char *sha1)\n \trev.verbose_header = 1;\n \trev.show_root_diff = 1;\n \tget_commit_format(format.buf, &rev);\n-\trev.always_show_header = 0;\n+\trev.always_show_header = 1;\n \trev.diffopt.detect_rename = 1;\n \trev.diffopt.rename_limit = 100;\n \trev.diffopt.break_opt = 0;\n@@ -1162,14 +1162,18 @@ static void print_summary(const char *prefix, const unsigned char *sha1)\n \t\t\t\thead,\n \t\tinitial_commit ? \" (root-commit)\" : \"\");\n\n-\tif (!log_tree_commit(&rev, commit)) {\n-\t\tstruct pretty_print_context ctx = {0};\n-\t\tstruct strbuf buf = STRBUF_INIT;\n-\t\tctx.date_mode = DATE_NORMAL;\n-\t\tformat_commit_message(commit, format.buf + 7, &buf, &ctx);\n-\t\tprintf(\"%s\\n\", buf.buf);\n-\t\tstrbuf_release(&buf);\n-\t}\n+\t/**\n+\t * Based on the existing underlying codepaths (log_tree_commit(),\n+\t * log_tree_diff(), log_tree_diff_flush(), to name a few), the die()\n+\t * should not occur; changes to these codepaths may warrant a revision\n+\t * of our handling of this situation.\n+\t *\n+\t * Tests #1-#3 in t7502 for output formats should aid in detecting such\n+\t * breakages.\n+\t */\n+\tif (!log_tree_commit(&rev, commit))\n+\t\tdie(\"unable to print summary\");\n+\n \tstrbuf_release(&format);\n }\n\ndiff --git a/t/t7502-commit.sh b/t/t7502-commit.sh\nindex b10541d..08c0247 100755\n--- a/t/t7502-commit.sh\n+++ b/t/t7502-commit.sh\n@@ -36,12 +36,12 @@ test_expect_success 'output summary format' '\n \tcheck_summary_oneline \"\" \"a change\"\n '\n\n-test_expect_failure 'output summary format for commit with an empty diff' '\n+test_expect_success 'output summary format for commit with an empty diff' '\n\n \tcheck_summary_oneline \"\" \"empty\" \"--allow-empty\"\n '\n\n-test_expect_failure 'output summary format for merges' '\n+test_expect_success 'output summary format for merges' '\n\n \tgit checkout -b recursive-base &&\n \ttest_commit base file1 &&\n--\n1.7.1.189.g07419\n"}]}