首页 \ 问答 \ Git附件与GitHub?(Git Annex with GitHub?)

Git附件与GitHub?(Git Annex with GitHub?)

我对git-annex不是很熟悉。 我刚刚阅读了文档,试图了解它。 我想到的思想,我无法确定的是:我可以在GitHub上托管一个git回购,并使用git和git附件将它推入其中,然后设置git附件以便它推动二进制文件喜欢一个S3桶,所有的源代码文件去GitHub?


I'm not very familiar with git-annex. I've just been reading the documentation trying to get my mind around it. The thought that has come to my mind, which I can't find certainty of is: Could I host a git repo on GitHub, and git push to it with git and git annex, but then set up git annex so that it pushes the binary files to like an S3 bucket, and all the source code files go to GitHub?


原文:https://stackoverflow.com/questions/29160241
更新时间:2022-04-07 17:04

最满意答案

让我们说返回的数组大小为8,它在内存中看起来像这样:

+---+
| c |
+---+
  |
  v
  +---+---+---+---+---+---+---+---+
  | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
  +---+---+---+---+---+---+---+---+

(里面的数字是索引。)

现在,如果你创建一个新的变量e指向c + size ,它将指向一个超出数据末尾的变量:

+---+                           +---+
| c |                           | e |
+---+                           +---+
  |                               |
  v                               v
  +---+---+---+---+---+---+---+---+
  | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
  +---+---+---+---+---+---+---+---+

如果你从e减去1它现在指向索引7

+---+                       +---+
| c |                       | e |
+---+                       +---+
  |                           |
  v                           v
  +---+---+---+---+---+---+---+---+
  | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
  +---+---+---+---+---+---+---+---+

如果你减去两个(总共) e将指向索引6 ,减去3并且e将指向索引5并且减去4并且指向的索引将是4 。 如果你减去5 ,指针e将指向索引3

+---+       +---+
| c |       | e |
+---+       +---+
  |           |
  v           v
  +---+---+---+---+---+---+---+---+
  | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
  +---+---+---+---+---+---+---+---+

而且距离结尾不是四个字节,距离结尾的五个字节。

所以你应该这样做

char* end = c + size - 4;  /* Subtract by 4 and not 5 */

如果数据来自其他系统,例如通过Internet,您还应该注意字节顺序


Lets say the returned array is of size 8, it would look something like this in memory:

+---+
| c |
+---+
  |
  v
  +---+---+---+---+---+---+---+---+
  | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
  +---+---+---+---+---+---+---+---+

(The numbers inside is the indexes.)

Now if you make a new variable e to point at c + size it will point point to one beyond the end of the data:

+---+                           +---+
| c |                           | e |
+---+                           +---+
  |                               |
  v                               v
  +---+---+---+---+---+---+---+---+
  | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
  +---+---+---+---+---+---+---+---+

If you subtract 1 from e it now points to index 7:

+---+                       +---+
| c |                       | e |
+---+                       +---+
  |                           |
  v                           v
  +---+---+---+---+---+---+---+---+
  | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
  +---+---+---+---+---+---+---+---+

If you subtract two (in total) e would point to index 6, subtract 3 and e would be pointing at index 5 and subtract 4 and the index pointed to would be 4. If you subtract 5 the pointer e would point to index 3:

+---+       +---+
| c |       | e |
+---+       +---+
  |           |
  v           v
  +---+---+---+---+---+---+---+---+
  | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
  +---+---+---+---+---+---+---+---+

And that's not four bytes from the end, that's five bytes from the end.

So you should be doing e.g.

char* end = c + size - 4;  /* Subtract by 4 and not 5 */

You should also be careful of the endianness, if the data comes from other systems e.g. over the Internet.

相关问答

更多
  • 您正在更改程序中的随机内存位置。 这是未定义的行为 ,它可能会对您的程序产生随机影响,例如分段错误。 You are changing a random memory location in your program. This is undefined behavior and it could have random effects on your program such as a segmentation fault.
  • “限制”不是C89,只有C99。 sizeof(float)可以!= 4在几台机器上。 此解决方案独立于sizeof(float),适用于所有ANSI C环境,并返回“float”中成功导入的浮动数。 int chars_to_floats(const char *chars, float *floats, int len) { int converted = 0; float *fp = (float*)chars; while( len >= sizeof*fp ) { *flo ...
  • 您需要以8个符号为一组拆分数组,并将每个组从二进制字符串表示转换为unsigned char。 例如: unsigned char byte = 0; for( int i = 0; i < 8; ++i ) if( a[i] == '1' ) byte |= 1 << (7-i); 然后将该字节放入另一个数组大小72/8并将其存储到文件中,例如通过std::ostream::write()方法。 您可以将位分组为16位,32位或64位,并使用uint16_t , uint32_t或uint64_ ...
  • 内存分配取决于平台/编译器。 malloc唯一确保的是它为你所要求的内容分配足够的内存 ,仅此而已。 由于内存对齐 ,无法保证您的地址是连续的 此外,您ints代码的大小分配而不是char 。 这很可能是您看到NUM_OF_CHARS*4差异的原因,而剩余差异可归因于填充。 Memory allocation is platform/compiler dependent. The only thing malloc ensures is that it allocates enough memory for ...
  • 您希望使用相同的数据类型写入和读取内存。 因此,如果您的图像存储为int,请使用int *写入数据结构并使用int *从数据结构中读取。 然后在最后一刻,将数据转换为double(而不是转换指针)。 You want to write and read the memory using the same data type. So if your image is stored as ints, use int* to write to your data structure and use int* to ...
  • 让我们说返回的数组大小为8,它在内存中看起来像这样: +---+ | c | +---+ | v +---+---+---+---+---+---+---+---+ | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | +---+---+---+---+---+---+---+---+ (里面的数字是索引。) 现在,如果你创建一个新的变量e指向c + size ,它将指向一个超出数据末尾的变量: +---+ +---+ ...
  • 为什么失败? 你在这里有一个错字。 std::cout<<(*((*double)number))<<" is my number.\n"; 它应该是: std::cout<<(*((double*)number))<<" is my number.\n"; 我该怎么办? 您可以减少使用的括号的数量。 std::cout<< *(double*)number <<" is my number.\n"; 你应该使用C ++类型转换而不是C类型转换,所以你很清楚你在做什么。 std::cout<< *re ...
  • 正如乔恩所说,目前尚不清楚,你需要什么。 也许你在谈论也许它是二元序列化你在寻找什么? As Jon mentioned, it's not clear, what you need. Maybe you are talking about maybe it is Binary serialization what you are looking for?
  • 你需要像这样施放它: int foo = *((int *) &buffer[0x8]); 它将首先将该点投射到一个int指针并将其解引用到int本身。 [注意不同机器类型的字节顺序; 有些做高字节首先有些做低] 为了确保这个例子很好理解,下面的代码展示了结果: #include main() { char buffer[14] = { 0,1,2,3,4,5,6,7,8,9,10,11,12,13 }; int foo = *((int *) &buffer[0x8 ...
  • 当一个数组传递给一个函数时,实际发生的是传递一个指向数组中第一个元素的指针。 换句话说,数组衰减成指向第一个元素的指针。 在这两个声明中: void test (char arrayT[]); void test2 (char *arrayU); 由于这种衰减, arrayT和arrayU的类型完全相同,而sizeof将为两者返回相同的值,即char *的大小。 将上述内容与此对比: char array1[] = "a string"; char *array2; 其中array1实际上是一个大小为9 ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)