]> Pileus Git - ~andy/git/commitdiff
clean up struct ref's nonfastforward field
authorJeff King <peff@peff.net>
Mon, 26 Mar 2012 19:51:50 +0000 (15:51 -0400)
committerJunio C Hamano <gitster@pobox.com>
Mon, 26 Mar 2012 19:59:04 +0000 (12:59 -0700)
Each ref structure contains a "nonfastforward" field which
is set during push to show whether the ref rewound history.
Originally this was a single bit, but it was changed in
f25950f (push: Provide situational hints for non-fast-forward
errors) to an enum differentiating a non-ff of the current
branch versus another branch.

However, we never actually set the member according to the
enum values, nor did we ever read it expecting anything but
a boolean value. But we did use the side effect of declaring
the enum constants to store those values in a totally
different integer variable. The code as-is isn't buggy, but
the enum declaration inside "struct ref" is somewhat
misleading.

Let's convert nonfastforward back into a single bit, and
then define the NON_FF_* constants closer to where they
would be used (they are returned via the "int *nonfastforward"
parameter to transport_push, so we can define them there).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
cache.h
transport.h

diff --git a/cache.h b/cache.h
index 427b600267a6f07fc00205648ead0c69a0118902..35f30752c612d4da31009eb0ef8a877743ee05b5 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -1009,6 +1009,7 @@ struct ref {
        char *symref;
        unsigned int force:1,
                merge:1,
+               nonfastforward:1,
                deletion:1;
        enum {
                REF_STATUS_NONE = 0,
@@ -1019,10 +1020,6 @@ struct ref {
                REF_STATUS_REMOTE_REJECT,
                REF_STATUS_EXPECTING_REPORT
        } status;
-       enum {
-               NON_FF_HEAD = 1,
-               NON_FF_OTHER
-       } nonfastforward;
        char *remote_status;
        struct ref *peer_ref; /* when renaming */
        char name[FLEX_ARRAY]; /* more */
index ce99ef8b7e1692b6b77bd7fbdee5858ce4bfc408..1631a35ea6332fb07e993ce42042ba9c8d037a21 100644 (file)
@@ -138,6 +138,8 @@ int transport_set_option(struct transport *transport, const char *name,
 void transport_set_verbosity(struct transport *transport, int verbosity,
        int force_progress);
 
+#define NON_FF_HEAD 1
+#define NON_FF_OTHER 2
 int transport_push(struct transport *connection,
                   int refspec_nr, const char **refspec, int flags,
                   int * nonfastforward);