1. 29 Jul, 2006 2 commits
  2. 28 Jul, 2006 1 commit
    • Junio C Hamano's avatar
      log and diff family: honor config even from subdirectories · ef1d9c5a
      Junio C Hamano authored
      There currently is an unfortunate circular dependency between
      what init_revisions (the command line revision specification
      parser) does and setting up the log and diff options.  The
      function uses setup_git_directory() to find the root of the
      project relative to the current directory and calls diff_setup()
      to prepare diff generation.  However, some of the things that
      diff_setup() does needs to depend on the configuration variable,
      which needs to be read after setup_git_directory() is called.
      
      This patch is a low impact workaround.  It first lets
      init_revisions() to run and do its thing, then uses git_config()
      and diff_setup() after it returns, so that configuration
      variables that affects the diff operation can be used from
      subdirectories.
      Signed-off-by: default avatarJunio C Hamano <[email protected]>
      ef1d9c5a
  3. 08 Jul, 2006 1 commit
    • Junio C Hamano's avatar
      diff: do not use configuration magic at the core-level · 83ad63cf
      Junio C Hamano authored
      The Porcelainish has become so much usable as the UI that there
      is not much reason people should be using the core programs by
      hand anymore.  At this point we are better off making the
      behaviour of the core programs predictable by keeping them
      unaffected by the configuration variables.  Otherwise they will
      become very hard to use as reliable building blocks.
      
      For example, "git-commit -a" internally uses git-diff-files to
      figure out the set of paths that need to be updated in the
      index, and we should never allow diff.renames that happens to be
      in the configuration to interfere (or slow down the process).
      
      The UI level configuration such as showing renamed diff and
      coloring are still honored by the Porcelainish ("git log" family
      and "git diff"), but not by the core anymore.
      Signed-off-by: default avatarJunio C Hamano <[email protected]>
      83ad63cf
  4. 02 Jul, 2006 1 commit
  5. 26 Jun, 2006 1 commit
  6. 20 Jun, 2006 1 commit
    • Linus Torvalds's avatar
      Add "named object array" concept · 1f1e895f
      Linus Torvalds authored
      We've had this notion of a "object_list" for a long time, which eventually
      grew a "name" member because some users (notably git-rev-list) wanted to
      name each object as it is generated.
      
      That object_list is great for some things, but it isn't all that wonderful
      for others, and the "name" member is generally not used by everybody.
      
      This patch splits the users of the object_list array up into two: the
      traditional list users, who want the list-like format, and who don't
      actually use or want the name. And another class of users that really used
      the list as an extensible array, and generally wanted to name the objects.
      
      The patch is fairly straightforward, but it's also biggish. Most of it
      really just cleans things up: switching the revision parsing and listing
      over to the array makes things like the builtin-diff usage much simpler
      (we now see exactly how many members the array has, and we don't get the
      objects reversed from the order they were on the command line).
      
      One of the main reasons for doing this at all is that the malloc overhead
      of the simple object list was actually pretty high, and the array is just
      a lot denser. So this patch brings down memory usage by git-rev-list by
      just under 3% (on top of all the other memory use optimizations) on the
      mozilla archive.
      
      It does add more lines than it removes, and more importantly, it adds a
      whole new infrastructure for maintaining lists of objects, but on the
      other hand, the new dynamic array code is pretty obvious. The change to
      builtin-diff-tree.c shows a fairly good example of why an array interface
      is sometimes more natural, and just much simpler for everybody.
      Signed-off-by: default avatarLinus Torvalds <[email protected]>
      Signed-off-by: default avatarJunio C Hamano <[email protected]>
      1f1e895f
  7. 23 May, 2006 1 commit
  8. 22 Apr, 2006 1 commit
    • Junio C Hamano's avatar
      Libify diff-files. · 6973dcae
      Junio C Hamano authored
      This is the first installment to libify diff brothers.
      
      The updated diff-files uses revision.c::setup_revisions()
      infrastructure to parse its command line arguments, which means
      the pathname arguments are checked more strictly than before.
      The tests are adjusted to separate possibly missing paths from
      the rest of arguments with double-dashes, to show the kosher
      way.
      
      As Linus pointed out, renaming diff.c to diff-lib.c was simply
      stupid, so I am renaming it back.  The new diff-lib.c is to
      contain pieces extracted from diff brothers.
      Signed-off-by: default avatarJunio C Hamano <[email protected]>
      6973dcae
  9. 17 Apr, 2006 1 commit
    • Linus Torvalds's avatar
      Log message printout cleanups · 91539833
      Linus Torvalds authored
      On Sun, 16 Apr 2006, Junio C Hamano wrote:
      >
      > In the mid-term, I am hoping we can drop the generate_header()
      > callchain _and_ the custom code that formats commit log in-core,
      > found in cmd_log_wc().
      
      Ok, this was nastier than expected, just because the dependencies between
      the different log-printing stuff were absolutely _everywhere_, but here's
      a patch that does exactly that.
      
      The patch is not very easy to read, and the "--patch-with-stat" thing is
      still broken (it does not call the "show_log()" thing properly for
      merges). That's not a new bug. In the new world order it _should_ do
      something like
      
      	if (rev->logopt)
      		show_log(rev, rev->logopt, "---\n");
      
      but it doesn't. I haven't looked at the --with-stat logic, so I left it
      alone.
      
      That said, this patch removes more lines than it adds, and in particular,
      the "cmd_log_wc()" loop is now a very clean:
      
      	while ((commit = get_revision(rev)) != NULL) {
      		log_tree_commit(rev, commit);
      		free(commit->buffer);
      		commit->buffer = NULL;
      	}
      
      so it doesn't get much prettier than this. All the complexity is entirely
      hidden in log-tree.c, and any code that needs to flush the log literally
      just needs to do the "if (rev->logopt) show_log(...)" incantation.
      
      I had to make the combined_diff() logic take a "struct rev_info" instead
      of just a "struct diff_options", but that part is pretty clean.
      
      This does change "git whatchanged" from using "diff-tree" as the commit
      descriptor to "commit", and I changed one of the tests to reflect that new
      reality. Otherwise everything still passes, and my other tests look fine
      too.
      Signed-off-by: default avatarLinus Torvalds <[email protected]>
      Signed-off-by: default avatarJunio C Hamano <[email protected]>
      91539833
  10. 30 Mar, 2006 1 commit
    • Junio C Hamano's avatar
      tree/diff header cleanup. · 1b0c7174
      Junio C Hamano authored
      Introduce tree-walk.[ch] and move "struct tree_desc" and
      associated functions from various places.
      
      Rename DIFF_FILE_CANON_MODE(mode) macro to canon_mode(mode) and
      move it to cache.h.  This macro returns the canonicalized
      st_mode value in the host byte order for files, symlinks and
      directories -- to be compared with a tree_desc entry.
      create_ce_mode(mode) in cache.h is similar but is intended to be
      used for index entries (so it does not work for directories) and
      returns the value in the network byte order.
      Signed-off-by: default avatarJunio C Hamano <[email protected]>
      1b0c7174
  11. 14 Feb, 2006 1 commit
  12. 09 Feb, 2006 2 commits
    • Junio C Hamano's avatar
      combine-diff: move formatting logic to show_combined_diff() · 0a798076
      Junio C Hamano authored
      This way, diff-files can make use of it.  Also implement the
      full suite of what diff_flush_raw() supports just for
      consistency.  With this, 'diff-tree -c -r --name-status' would
      show what is expected.
      
      There is no way to get the historical output (useful for
      debugging and low-level Plumbing work) anymore, so tentatively
      it makes '-m' to mean "do not combine and show individual diffs
      with parents".
      
      diff-files matches diff-tree to produce raw output for -c.  For
      textual combined diff, use -p -c.
      Signed-off-by: default avatarJunio C Hamano <[email protected]>
      0a798076
    • Junio C Hamano's avatar
      "Assume unchanged" git · 5f73076c
      Junio C Hamano authored
      This adds "assume unchanged" logic, started by this message in the list
      discussion recently:
      
      	<[email protected]>
      
      This is a workaround for filesystems that do not have lstat()
      that is quick enough for the index mechanism to take advantage
      of.  On the paths marked as "assumed to be unchanged", the user
      needs to explicitly use update-index to register the object name
      to be in the next commit.
      
      You can use two new options to update-index to set and reset the
      CE_VALID bit:
      
      	git-update-index --assume-unchanged path...
      	git-update-index --no-assume-unchanged path...
      
      These forms manipulate only the CE_VALID bit; it does not change
      the object name recorded in the index file.  Nor they add a new
      entry to the index.
      
      When the configuration variable "core.ignorestat = true" is set,
      the index entries are marked with CE_VALID bit automatically
      after:
      
       - update-index to explicitly register the current object name to the
         index file.
      
       - when update-index --refresh finds the path to be up-to-date.
      
       - when tools like read-tree -u and apply --index update the working
         tree file and register the current object name to the index file.
      
      The flag is dropped upon read-tree that does not check out the index
      entry.  This happens regardless of the core.ignorestat settings.
      
      Index entries marked with CE_VALID bit are assumed to be
      unchanged most of the time.  However, there are cases that
      CE_VALID bit is ignored for the sake of safety and usability:
      
       - while "git-read-tree -m" or git-apply need to make sure
         that the paths involved in the merge do not have local
         modifications.  This sacrifices performance for safety.
      
       - when git-checkout-index -f -q -u -a tries to see if it needs
         to checkout the paths.  Otherwise you can never check
         anything out ;-).
      
       - when git-update-index --really-refresh (a new flag) tries to
         see if the index entry is up to date.  You can start with
         everything marked as CE_VALID and run this once to drop
         CE_VALID bit for paths that are modified.
      
      Most notably, "update-index --refresh" honours CE_VALID and does
      not actively stat, so after you modified a file in the working
      tree, update-index --refresh would not notice until you tell the
      index about it with "git-update-index path" or "git-update-index
      --no-assume-unchanged path".
      
      This version is not expected to be perfect.  I think diff
      between index and/or tree and working files may need some
      adjustment, and there probably needs other cases we should
      automatically unmark paths that are marked to be CE_VALID.
      
      But the basics seem to work, and ready to be tested by people
      who asked for this feature.
      Signed-off-by: default avatarJunio C Hamano <[email protected]>
      5f73076c
  13. 06 Feb, 2006 2 commits
  14. 28 Jan, 2006 2 commits
  15. 30 Nov, 2005 2 commits
    • Junio C Hamano's avatar
      diff-files: show diffs with stage0 and unmerged stage at the same time. · 15bf57a1
      Junio C Hamano authored
      After thinking about it more, I realized that much of the change
      I did on top of Linus' version does not make much sense.  This
      commit reverts it so that it by default shows diffs with stage0
      paths or stage2 paths with working tree; the unmerged stage to
      use can be overridden with -1/-2/-3 option (-2 is the default so
      essentially is a no-op).
      
      When the index file is unmerged, we are by definition in the
      middle of a conflicting merge, and we should show the diff with
      stage 2 by default.  More importantly, paths without conflicts
      are updated in the working tree and collapsed to stage0 in the
      index, so showing diff with stage0 at the same time does not
      hurt.  In normal cases, stage0 entries should be in sync with
      the working tree files and does not clutter the output.  It even
      helps the user to realize that the working tree has local
      changes unrelated to the merge and remember to be careful not to
      do a "git-commit -a" after resolving the conflicts.
      
      When there is no unmerged entries, giving diff_unmerged_stage a
      default value of 2 does not cause any harm, because it would not
      be used anyway.  So in all, always showing diff between stage0
      paths and unmerged entries from a stage (defaulting to 2) is the
      right thing to do, as Linus originally did.
      Signed-off-by: default avatarJunio C Hamano <[email protected]>
      15bf57a1
    • Linus Torvalds's avatar
      diff-files: -1/-2/-3 to diff against unmerged stage. · 10637b84
      Linus Torvalds authored
      While resolving conflicted merge, it was not easy to compare the
      working tree file with unmerged index entries.  This commit
      introduces new options -1/-2/-3 (with synonyms --base, --ours,
      and --theirs) to compare working tree files with specified
      stages.
      
      When none of these options are given, the command defaults to -2
      if the index file is unmerged, otherwise it acts as before.
      
      [jc: majorly butchered from the version Linus originally posted.]
      Signed-off-by: default avatarJunio C Hamano <[email protected]>
      10637b84
  16. 22 Nov, 2005 1 commit
  17. 18 Oct, 2005 1 commit
  18. 12 Oct, 2005 1 commit
    • Junio C Hamano's avatar
      Use core.filemode. · 3e09cdfd
      Junio C Hamano authored
      With "[core] filemode = false", you can tell git to ignore
      differences in the working tree file only in executable bit.
      
       * "git-update-index --refresh" does not say "needs update" if index
         entry and working tree file differs only in executable bit.
      
       * "git-update-index" on an existing path takes executable bit
         from the existing index entry, if the path and index entry are
         both regular files.
      
       * "git-diff-files" and "git-diff-index" without --cached flag
         pretend the path on the filesystem has the same executable
         bit as the existing index entry, if the path and index entry
         are both regular files.
      
      If you are on a filesystem with unreliable mode bits, you may need to
      force the executable bit after registering the path in the index.
      
       * "git-update-index --chmod=+x foo" flips the executable bit of the
         index file entry for path "foo" on.  Use "--chmod=-x" to flip it
         off.
      
      Note that --chmod only works in index file and does not look at nor
      update the working tree.
      
      So if you are on a filesystem and do not have working executable bit,
      you would do:
      
       1. set the appropriate .git/config option;
      
       2. "git-update-index --add new-file.c"
      
       3. "git-ls-files --stage new-file.c" to see if it has the desired
         mode bits.  If not, e.g. to drop executable bit picked up from the
         filesystem, say "git-update-index --chmod=-x new-file.c".
      Signed-off-by: default avatarJunio C Hamano <[email protected]>
      3e09cdfd
  19. 10 Oct, 2005 1 commit
    • Linus Torvalds's avatar
      Add ".git/config" file parser · 17712991
      Linus Torvalds authored
      This is a first cut at a very simple parser for a git config file.
      
      The format of the file is a simple ini-file like thing, with simple
      variable/value pairs. You can (and should) make the variables have a
      simple single-level scope, ie a valid file looks something like this:
      
      	#
      	# This is the config file, and
      	# a '#' or ';' character indicates
      	# a comment
      	#
      
      	; core variables
      	[core]
      		; Don't trust file modes
      		filemode = false
      
      	; Our diff algorithm
      	[diff]
      		external = "/usr/local/bin/gnu-diff -u"
      		renames = true
      
      which parses into three variables: "core.filemode" is associated with the
      string "false", and "diff.external" gets the appropriate quoted value.
      
      Right now we only react to one variable: "core.filemode" is a boolean that
      decides if we should care about the 0100 (user-execute) bit of the stat
      information. Even that is just a parsing demonstration - this doesn't
      actually implement that st_mode compare logic itself.
      
      Different programs can react to different config options, although they
      should always fall back to calling "git_default_config()" on any config
      option name that they don't recognize.
      Signed-off-by: default avatarLinus Torvalds <[email protected]>
      Signed-off-by: default avatarJunio C Hamano <[email protected]>
      17712991
  20. 01 Oct, 2005 1 commit
  21. 25 Sep, 2005 1 commit
  22. 17 Aug, 2005 1 commit
  23. 30 Jul, 2005 1 commit
  24. 15 Jul, 2005 1 commit
    • Linus Torvalds's avatar
      Split up "diff_format" into "format" and "line_termination". · e68b6f15
      Linus Torvalds authored
      This removes the separate "formats" for name and name-with-zero-
      termination.
      
      It also removes the difference between HUMAN and MACHINE formats, and
      they both become DIFF_FORMAT_RAW, with the difference being just in the
      line and inter-filename termination.
      
      It also makes the code easier to understand.
      e68b6f15
  25. 14 Jul, 2005 1 commit
  26. 13 Jul, 2005 2 commits
  27. 08 Jul, 2005 1 commit
  28. 20 Jun, 2005 1 commit
    • Junio C Hamano's avatar
      [PATCH] Make -C less eager. · 4727f640
      Junio C Hamano authored
      Like diff-tree, this patch makes -C option for diff-* brothers
      to use only pre-image of modified files as rename/copy detection
      by default.  Give --find-copies-harder to use unmodified files
      to find copies from as well.
      
      This also fixes "diff-files -C" problem earlier noticed by
      Linus.  It was feeding the null sha1 even when the file in the
      work tree was known to match what is in the index file.  This
      resulted in diff-files showing everything in the project.
      Signed-off-by: default avatarJunio C Hamano <[email protected]>
      Signed-off-by: default avatarLinus Torvalds <[email protected]>
      4727f640
  29. 13 Jun, 2005 1 commit
    • Junio C Hamano's avatar
      [PATCH] Add --diff-filter= output restriction to diff-* family. · f2ce9fde
      Junio C Hamano authored
      This is a halfway between debugging aid and a helper to write an
      ultra-smart merge scripts.  The new option takes a string that
      consists of a list of "status" letters, and limits the diff
      output to only those classes of changes, with two exceptions:
      
       - A broken pair (aka "complete rewrite"), does not match D
         (deleted) or N (created).  Use B to look for them.
      
       - The letter "A" in the diff-filter string does not match
         anything itself, but causes the entire diff that contains
         selected patches to be output (this behaviour is similar to
         that of --pickaxe-all for the -S option).
      
      For example,
      
          $ git-rev-list HEAD |
            git-diff-tree --stdin -s -v -B -C --diff-filter=BCR
      
      shows a list of commits that have complete rewrite, copy, or
      rename.
      Signed-off-by: default avatarJunio C Hamano <[email protected]>
      Signed-off-by: default avatarLinus Torvalds <[email protected]>
      f2ce9fde
  30. 03 Jun, 2005 2 commits
    • Junio C Hamano's avatar
      [PATCH] diff: Clean up diff_scoreopt_parse(). · 0e3994fa
      Junio C Hamano authored
      This cleans up diff_scoreopt_parse() function that is used to
      parse the fractional notation -B, -C and -M option takes.  The
      callers are modified to check for errors and complain.  Earlier
      they silently ignored malformed input and falled back on the
      default.
      Signed-off-by: default avatarJunio C Hamano <[email protected]>
      Signed-off-by: default avatarLinus Torvalds <[email protected]>
      0e3994fa
    • Junio C Hamano's avatar
      [PATCH] diff: Fix docs and add -O to diff-helper. · ce240675
      Junio C Hamano authored
      This patch updates diff documentation and usage strings:
      
       - clarify the semantics of -R.  It is not "output in reverse";
         rather, it is "I will feed diff backwards".  Semantically
         they are different when -C is involved.
      
       - describe -O in usage strings of diff-* brothers.  It was
         implemented, documented but not described in usage text.
      
      Also it adds -O to diff-helper.  Like -S (and unlike -M/-C/-B),
      this option can work on sanitized diff-raw output produced by
      the diff-* brothers.  While we are at it, the call it makes to
      diffcore is cleaned up to use the diffcore_std() like everybody
      else, and the declaration for the low level diffcore routines
      are moved from diff.h (public) to diffcore.h (private between
      diff.c and diffcore backends).
      Signed-off-by: default avatarJunio C Hamano <[email protected]>
      Signed-off-by: default avatarLinus Torvalds <[email protected]>
      ce240675
  31. 01 Jun, 2005 1 commit
    • Junio C Hamano's avatar
      [PATCH] diff: mode bits fixes · 67574c40
      Junio C Hamano authored
      The core GIT repository has trees that record regular file mode
      in 0664 instead of normalized 0644 pattern.  Comparing such a
      tree with another tree that records the same file in 0644
      pattern without content changes with git-diff-tree causes it to
      feed otherwise unmodified pairs to the diff_change() routine,
      which triggers a sanity check routine and barfs.  This patch
      fixes the problem, along with the fix to another caller that
      uses unnormalized mode bits to call diff_change() routine in a
      similar way.
      
      Without this patch, you will see "fatal error" from diff-tree
      when you run git-deltafy-script on the core GIT repository
      itself.
      Signed-off-by: default avatarJunio C Hamano <[email protected]>
      Signed-off-by: default avatarLinus Torvalds <[email protected]>
      67574c40
  32. 31 May, 2005 1 commit
  33. 30 May, 2005 1 commit
    • Junio C Hamano's avatar
      [PATCH] Add -B flag to diff-* brothers. · f345b0a0
      Junio C Hamano authored
      A new diffcore transformation, diffcore-break.c, is introduced.
      
      When the -B flag is given, a patch that represents a complete
      rewrite is broken into a deletion followed by a creation.  This
      makes it easier to review such a complete rewrite patch.
      
      The -B flag takes the same syntax as the -M and -C flags to
      specify the minimum amount of non-source material the resulting
      file needs to have to be considered a complete rewrite, and
      defaults to 99% if not specified.
      
      As the new test t4008-diff-break-rewrite.sh demonstrates, if a
      file is a complete rewrite, it is broken into a delete/create
      pair, which can further be subjected to the usual rename
      detection if -M or -C is used.  For example, if file0 gets
      completely rewritten to make it as if it were rather based on
      file1 which itself disappeared, the following happens:
      
          The original change looks like this:
      
      	file0     --> file0' (quite different from file0)
      	file1     --> /dev/null
      
          After diffcore-break runs, it would become this:
      
      	file0     --> /dev/null
      	/dev/null --> file0'
      	file1     --> /dev/null
      
          Then diffcore-rename matches them up:
      
      	file1     --> file0'
      
      The internal score values are finer grained now.  Earlier
      maximum of 10000 has been raised to 60000; there is no user
      visible changes but there is no reason to waste available bits.
      Signed-off-by: default avatarJunio C Hamano <[email protected]>
      Signed-off-by: default avatarLinus Torvalds <[email protected]>
      f345b0a0