Staging chunks can get confused

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Tonight I was staging changes with `git add -p` and noticed they got
applied at the *wrong* location.
My guess is that when you stage a hunk it doesn't do a line number
fix-up for earlier unstaged hunks in the file.

Screencast: https://asciinema.org/a/7y9qhr0837a7t96m8w14mupnk
Alternatively, an example follows:

$ git add -p
diff --git a/unistring/unistring.c b/unistring/unistring.c
index 62bbc8a..45ced5d 100644
--- a/unistring/unistring.c
+++ b/unistring/unistring.c
@@ -17,6 +17,27 @@ static const char *const uninormnames[] = {"NFD",
"NFC", "NFKD", "NFKC", NULL};
 #define lunistring_optuninorm(L, arg)
(lua_isnoneornil(L,(arg))?NULL:lunistring_checkuninorm((L), (arg)))


+const uint8_t * u8_check (const uint8_t *s, size_t n);
+int u8_mblen (const uint8_t *s, size_t n);
+int u8_mbtouc_unsafe (ucs4_t *puc, const uint8_t *s, size_t n);
+int u8_mbtouc (ucs4_t *puc, const uint8_t *s, size_t n);
+int u8_mbtoucr (ucs4_t *puc, const uint8_t *s, size_t n);
+int u8_uctomb (uint8_t *s, ucs4_t uc, int n);
+size_t u8_mbsnlen (const uint8_t *s, size_t n);
+
+int u8_strmblen (const uint8_t *s);
+int u8_strmbtouc (ucs4_t *puc, const uint8_t *s);
+const uint8_t * u8_next (ucs4_t *puc, const uint8_t *s);
+const uint8_t * u8_prev (ucs4_t *puc, const uint8_t *s, const uint8_t *start);
+
+uint8_t * u8_conv_from_encoding (const char *fromcode, enum
iconv_ilseq_handler handler, const char *src, size_t srclen, size_t
*offsets, uint8_t *resultbuf, size_t *lengthp);
+char * u8_conv_to_encoding (const char *tocode, enum
iconv_ilseq_handler handler, const uint8_t *src, size_t srclen, size_t
*offsets, char *resultbuf, size_t *lengthp);
+uint8_t * u8_strconv_from_encoding (const char *string, const char
*fromcode, enum iconv_ilseq_handler handler);
+char * u8_strconv_to_encoding (const uint8_t *string, const char
*tocode, enum iconv_ilseq_handler handler);
+uint8_t * u8_strconv_from_locale (const char *string);
+char * u8_strconv_to_locale (const uint8_t *string);
+
+
 static int lunistring_width(lua_State *L) {
  size_t n;
  const uint8_t *s = (const uint8_t*)luaL_checklstring(L, 1, &n);
Stage this hunk [y,n,q,a,d,/,j,J,g,e,?]? n
@@ -27,6 +48,17 @@ static int lunistring_width(lua_State *L) {
 }


+int u8_strwidth (const uint8_t *s, const char *encoding);
+void u8_wordbreaks (const uint8_t *s, size_t n, char *p);
+void u8_possible_linebreaks (const uint8_t *s, size_t n, const char
*encoding, char *p);
+int u8_width_linebreaks (const uint8_t *s, size_t n, int width, int
start_column, int at_end_columns, const char *override, const char
*encoding, char *p);
+
+
+int uc_decomposition (ucs4_t uc, int *decomp_tag, ucs4_t *decomposition);
+int uc_canonical_decomposition (ucs4_t uc, ucs4_t *decomposition);
+ucs4_t uc_composition (ucs4_t uc1, ucs4_t uc2);
+
+
 static int lunistring_normalize(lua_State *L) {
  uninorm_t nf = lunistring_optuninorm(L, 1);
  size_t n;
Stage this hunk [y,n,q,a,d,/,K,j,J,g,e,?]? n
@@ -54,6 +86,9 @@ static int lunistring_normalize(lua_State *L) {
 }


+int u8_normcmp (const uint8_t *s1, size_t n1, const uint8_t *s2,
size_t n2, uninorm_t nf, int *resultp);
+
+
 static int lunistring_normxfrm(lua_State *L) {
  size_t n;
  const uint8_t *s = (const uint8_t*)luaL_checklstring(L, 1, &n);
Stage this hunk [y,n,q,a,d,/,K,j,J,g,e,?]? n
@@ -83,6 +118,9 @@ static int lunistring_normxfrm(lua_State *L) {
 }


+int u8_normcoll (const uint8_t *s1, size_t n1, const uint8_t *s2,
size_t n2, uninorm_t nf, int *resultp);
+
+
 static int lunistring_uc_locale_language(lua_State *L) {
  lua_pushstring(L, uc_locale_language());
  return 1;
Stage this hunk [y,n,q,a,d,/,K,j,J,g,e,?]? n
@@ -173,6 +211,15 @@ static int lunistring_totitle(lua_State *L) {
 }


+casing_prefix_context_t u8_casing_prefix_context (const uint8_t *s, size_t n);
+casing_prefix_context_t u8_casing_prefixes_context (const uint8_t *s,
size_t n, casing_prefix_context_t a_context);
+casing_suffix_context_t u8_casing_suffix_context (const uint8_t *s, size_t n);
+casing_suffix_context_t u8_casing_suffixes_context (const uint8_t *s,
size_t n, casing_suffix_context_t a_context);
+uint8_t * u8_ct_toupper (const uint8_t *s, size_t n,
casing_prefix_context_t prefix_context, casing_suffix_context_t
suffix_context, const char *iso639_language, uninorm_t nf, uint8_t
*resultbuf, size_t *lengthp);
+uint8_t * u8_ct_tolower (const uint8_t *s, size_t n,
casing_prefix_context_t prefix_context, casing_suffix_context_t
suffix_context, const char *iso639_language, uninorm_t nf, uint8_t
*resultbuf, size_t *lengthp);
+uint8_t * u8_ct_totitle (const uint8_t *s, size_t n,
casing_prefix_context_t prefix_context, casing_suffix_context_t
suffix_context, const char *iso639_language, uninorm_t nf, uint8_t
*resultbuf, size_t *lengthp);
+
+
 static int lunistring_casefold(lua_State *L) {
  size_t n;
  const uint8_t *s = (const uint8_t*)luaL_checklstring(L, 1, &n);
Stage this hunk [y,n,q,a,d,/,K,j,J,g,e,?]? n
@@ -201,6 +248,10 @@ static int lunistring_casefold(lua_State *L) {
 }


+uint8_t * u8_ct_casefold (const uint8_t *s, size_t n,
casing_prefix_context_t prefix_context, casing_suffix_context_t
suffix_context, const char *iso639_language, uninorm_t nf, uint8_t
*resultbuf, size_t *lengthp);
+int u8_casecmp (const uint8_t *s1, size_t n1, const uint8_t *s2,
size_t n2, const char *iso639_language, uninorm_t nf, int *resultp);
+
+
 static int lunistring_casexfrm(lua_State *L) {
  size_t n;
  const uint8_t *s = (const uint8_t*)luaL_checklstring(L, 1, &n);
Stage this hunk [y,n,q,a,d,/,K,j,J,g,e,?]? n
@@ -230,6 +281,9 @@ static int lunistring_casexfrm(lua_State *L) {
 }


+int u8_casecoll (const uint8_t *s1, size_t n1, const uint8_t *s2,
size_t n2, const char *iso639_language, uninorm_t nf, int *resultp);
+
+
 static int lunistring_casecoll(lua_State *L) {
  size_t n1, n2;
  const uint8_t *s1 = (const uint8_t*)luaL_checklstring(L, 1, &n1);
Stage this hunk [y,n,q,a,d,/,K,j,J,g,e,?]? n
@@ -288,7 +342,7 @@ static int lunistring_is_titlecase(lua_State *L) {
  return luaL_fileresult(L, 0, NULL);
  }

- lua_pushboolean(L, resultp);
+ lua_pushinteger(L, resultp);
  return 1;
 }

Stage this hunk [y,n,q,a,d,/,K,g,e,?]? y

$ git diff --cached
diff --git a/unistring/unistring.c b/unistring/unistring.c
index 62bbc8a..ea85d65 100644
--- a/unistring/unistring.c
+++ b/unistring/unistring.c
@@ -318,7 +318,7 @@ static int lunistring_is_cased(lua_State *L) {
                return luaL_fileresult(L, 0, NULL);
        }

-       lua_pushboolean(L, resultp);
+       lua_pushinteger(L, resultp);
        return 1;
 }



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]