Я наблюдаю поведение в Git, которое мне кажется очень загадочным.
Я храню клон репозитория Linux от Github для локальной игры с Git. Чтобы быть ясным, я мало что делаю в этом репозитории: я получаю изменения, обновляю master
, проверяю конкретную версию и иногда пробую графический интерфейс Git, чтобы посмотреть, как выглядит визуализация на большом проект.
Версия TL; DR: Я никогда не вносил никаких изменений в файлы в нем .
Сегодня я извлек master
и извлек изменения из Github. Казалось, все идет нормально. Но я подозреваю, что на самом деле это не так. Вот как теперь выглядит git status
.
axel@macbook ~/Depots/linux $ git status
# On branch master
# Changes not staged for commit:
# (use "git add ..." to update what will be committed)
# (use "git checkout -- ..." to discard changes in working directory)
#
# modified: include/linux/netfilter/xt_connmark.h
# modified: include/linux/netfilter/xt_dscp.h
# modified: include/linux/netfilter/xt_mark.h
# modified: include/linux/netfilter/xt_rateest.h
# modified: include/linux/netfilter/xt_tcpmss.h
# modified: include/linux/netfilter_ipv4/ipt_ecn.h
# modified: include/linux/netfilter_ipv4/ipt_ttl.h
# modified: include/linux/netfilter_ipv6/ip6t_hl.h
# modified: net/ipv4/netfilter/ipt_ecn.c
# modified: net/netfilter/xt_dscp.c
# modified: net/netfilter/xt_hl.c
# modified: net/netfilter/xt_rateest.c
# modified: net/netfilter/xt_tcpmss.c
#
# Untracked files:
# (use "git add ..." to include in what will be committed)
#
# samples/hidraw/
no changes added to commit (use "git add" and/or "git commit -a")
Интересно, откуда берутся эти изменения? А теперь самое худшее. Посмотрим, что произойдет, если я попытаюсь избавиться от этих файлов и снова их проверить.
axel@macbook ~/Depots/linux $ rm -Rf include net
axel@macbook ~/Depots/linux $ git checkout -- .
axel@macbook ~/Depots/linux $ git status
# On branch master
# Changes not staged for commit:
# (use "git add ..." to update what will be committed)
# (use "git checkout -- ..." to discard changes in working directory)
#
# modified: include/linux/netfilter/xt_CONNMARK.h
# modified: include/linux/netfilter/xt_DSCP.h
# modified: include/linux/netfilter/xt_MARK.h
# modified: include/linux/netfilter/xt_RATEEST.h
# modified: include/linux/netfilter/xt_TCPMSS.h
# modified: include/linux/netfilter_ipv4/ipt_ECN.h
# modified: include/linux/netfilter_ipv4/ipt_TTL.h
# modified: include/linux/netfilter_ipv6/ip6t_HL.h
# modified: net/ipv4/netfilter/ipt_ECN.c
# modified: net/netfilter/xt_DSCP.c
# modified: net/netfilter/xt_HL.c
# modified: net/netfilter/xt_RATEEST.c
# modified: net/netfilter/xt_TCPMSS.c
#
# Untracked files:
# (use "git add ..." to include in what will be committed)
#
# samples/hidraw/
no changes added to commit (use "git add" and/or "git commit -a")
Ну, тоже самое.
Похоже, что операция git checkout
создает файлы с загадочными изменениями.
Я попытался продолжить расследование и мне кажется, что я исключил возможность того, что эти изменения были вызваны проблемами с окончанием строки .См. Начало git diff
ниже
diff --git a/include/linux/netfilter/xt_CONNMARK.h b/include/linux/netfilter/xt_CONNMARK.h
index 2f2e48e..efc17a8 100644
--- a/include/linux/netfilter/xt_CONNMARK.h
+++ b/include/linux/netfilter/xt_CONNMARK.h
@@ -1,6 +1,31 @@
-#ifndef _XT_CONNMARK_H_target
-#define _XT_CONNMARK_H_target
+#ifndef _XT_CONNMARK_H
+#define _XT_CONNMARK_H
-#include
+#include
-#endif /*_XT_CONNMARK_H_target*/
+/* Copyright (C) 2002,2004 MARA Systems AB
+ * by Henrik Nordstrom
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
Если я правильно понимаю, здесь показаны изменения, которые нельзя было сделать, просто изменив некоторые окончания строк, верно?
Последнее, что я сделал, это : попытаться выяснить автора изменений, но, очевидно, это не сработало. См. Следующий вывод git blame
.
axel@macbook ~/Depots/linux $ git blame include/linux/netfilter/xt_CONNMARK.h
00000000 (Not Committed Yet 2011-10-25 20:00:56 +0200 1) #ifndef _XT_CONNMARK_H
00000000 (Not Committed Yet 2011-10-25 20:00:56 +0200 2) #define _XT_CONNMARK_H
2e4e6a17 (Harald Welte 2006-01-12 13:30:04 -0800 3)
00000000 (Not Committed Yet 2011-10-25 20:00:56 +0200 4) #include
0dc8c760 (Jan Engelhardt 2008-01-14 23:38:34 -0800 5)
00000000 (Not Committed Yet 2011-10-25 20:00:56 +0200 6) /* Copyright (C) 2002,2004 MARA Systems AB
00000000 (Not Committed Yet 2011-10-25 20:00:56 +0200 7) * by Henrik Nordstrom
00000000 (Not Committed Yet 2011-10-25 20:00:56 +0200 8) *
00000000 (Not Committed Yet 2011-10-25 20:00:56 +0200 9) * This program is free software; you can redistribute it and/or modify
00000000 (Not Committed Yet 2011-10-25 20:00:56 +0200 10) * it under the terms of the GNU General Public License as published by
00000000 (Not Committed Yet 2011-10-25 20:00:56 +0200 11) * the Free Software Foundation; either version 2 of the License, or
00000000 (Not Committed Yet 2011-10-25 20:00:56 +0200 12) * (at your option) any later version.
00000000 (Not Committed Yet 2011-10-25 20:00:56 +0200 13) */
Что мне не хватает? Когда я мог ошибиться и как это исправить? Спасибо за ваши советы и замечания!