From: Jonathan Nieder <jrnieder@gmail.com>
To: Yann Dirson <ydirson@altern.org>
Cc: git@vger.kernel.org, Yann Dirson <ydirson@free.fr>
Subject: Re: [PATCH v8 1/5] Introduce bulk-move detection in diffcore.
Date: Thu, 28 Oct 2010 20:45:40 -0500 [thread overview]
Message-ID: <20101029014540.GB28984@burratino> (raw)
In-Reply-To: <1288303712-14662-2-git-send-email-ydirson@altern.org>
Yann Dirson wrote:
> Possible optimisations to this code include:
> * avoid use of i_am_not_single by using a separate list
I think that would help code clarity, too. It is tempting to try to
split this patch into micropatches:
1. introduce DETECT_DIRECTORY_RENAMES flag and hidden UI for it.
2. if detecting bulk relocations, do not simplify input for
diffcore by omitting unchanged files (just like when
finding copies harder).
3. introduce "rename target candidate" flag in rename_dsts.
- if detecting copies, all diff targets are potential rename
targets
- if detecting bulk relocations but not copies, all diff
targets are rename_dsts, but only file creation diff
targets are potential rename targets
- if detecting neither bulk reloc nor copies, only file
creation diff targets are rename_dsts (and all are
potential rename targets).
Alternatively, rename_dsts that are not potential rename targets
could be put in a different list (which is simpler and probably
faster, while using a little more memory).
4. honor rename_target_candidate flag (not needed if the
non-candidates get their own list).
5. introduce a list of potential directory relocations and functions
to manipulate it.
6. pass the (empty) list of relocated directories back to diffcore.
7. populate the list of directory relocation candidates. If a file
has been renamed to go from directory a/ to directory b/, we have a
directory rename candidate.
8. disqualify directories with stragglers left behind.
9. disqualify directories for which the contents are not unanimous
about where to go.
10. add documentation and stop hiding the UI.
Trivial comments on the patch:
[...]
> +++ b/diffcore-rename.c
> @@ -6,14 +6,34 @@
> #include "diffcore.h"
> #include "hash.h"
>
> +#define DEBUG_BULKMOVE 0
> +
> +#if DEBUG_BULKMOVE
> +#define debug_bulkmove(args) __debug_bulkmove args
> +void __debug_bulkmove(const char *fmt, ...)
> +{
> + va_list ap;
> + va_start(ap, fmt);
> + fprintf(stderr, "[DBG] ");
> + vfprintf(stderr, fmt, ap);
> + va_end(ap);
> +}
> +#else
> +#define debug_bulkmove(args) do { /*nothing */ } while (0)
> +#endif
Is the debugging output infrequent enough to just use a function
unconditionally?
[...]
> + * Supports in-place modification of src by passing dst == src.
> + */
> +static const char *copy_dirname(char *dst, const char *src)
[...]
> + end = mempcpy(dst, src, slash - src + 1);
I suppose this should read:
if (dst != src)
memcpy(dst, src, slash - src + 1);
dst[slash - src + 1] = '\0';
return dst;
[...]
> +static int discard_if_outside(struct diff_bulk_rename *candidate,
> + struct diff_bulk_rename *seen) {
Style: '{' for functions goes in column 0.
> + if (!prefixcmp(candidate->two->path, seen->two->path)) {
> + debug_bulkmove((" 'dstpair' conforts 'seen'\n"));
> + return 0;
> + } else {
Can get some depth reduction by dropping the else here (since in
the trivial case we have already returned).
> +static void diffcore_bulk_moves(void)
> +{
> + int i;
> + for (i = 0; i < rename_dst_nr; i++)
> + check_one_bulk_move(rename_dst[i].pair);
> +}
Yay. :)
next prev parent reply other threads:[~2010-10-29 1:45 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-28 22:08 [PATCH v8] Detection of directory renames Yann Dirson
2010-10-28 22:08 ` [PATCH v8 1/5] Introduce bulk-move detection in diffcore Yann Dirson
2010-10-29 1:45 ` Jonathan Nieder [this message]
2010-10-29 21:18 ` Yann Dirson
2010-10-30 0:26 ` Jonathan Nieder
2010-11-04 21:56 ` Yann Dirson
2010-11-04 21:59 ` [PATCH] " Yann Dirson
2010-11-25 10:08 ` [PATCH v8 1/5] " Ævar Arnfjörð Bjarmason
2010-11-25 15:02 ` Jonathan Nieder
2010-11-25 17:19 ` Ævar Arnfjörð Bjarmason
2010-10-28 22:08 ` [PATCH v8 2/5] Raw diff output format for bulk moves Yann Dirson
2010-10-28 22:08 ` [PATCH v8 3/5] Add testcases for the --detect-bulk-moves diffcore flag Yann Dirson
2010-10-28 22:08 ` [PATCH v8 4/5] Unified diff output format for bulk moves Yann Dirson
2010-10-28 22:08 ` [PATCH v8 5/5] [WIP] Allow hiding renames of individual files involved in a directory rename Yann Dirson
2010-10-29 1:05 ` [PATCH v8] Detection of directory renames Jonathan Nieder
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20101029014540.GB28984@burratino \
--to=jrnieder@gmail.com \
--cc=git@vger.kernel.org \
--cc=ydirson@altern.org \
--cc=ydirson@free.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).